涩里番 v4.2版本的 MD5 值为:b7af51031b798a68c7a3a9ba5a0dff66
以下内容为反编译后的 a.java 源代码,内容仅作参考
package r0;
import af.j;
import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
import com.google.android.material.datepicker.UtcDates;
import com.luck.picture.lib.camera.CustomCameraView;
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
import l.o;
public final class a {
public static SimpleDateFormat Q;
public static final e U;
public static final e[][] V;
public static final e[] W;
public static final e X;
public static final e Y;
public static final HashMap<Integer, e>[] Z;
public static final HashMap<String, e>[] f14289a0;
public static final HashSet<String> f14290b0;
public static final HashMap<Integer, Integer> f14291c0;
public static final Charset f14292d0;
public static final byte[] f14293e0;
public static final byte[] f14294f0;
public static final Pattern f14295g0;
public String f14304a;
public FileDescriptor f14305b;
public AssetManager.AssetInputStream f14306c;
public int f14307d;
public final HashMap<String, d>[] f14308e;
public Set<Integer> f14309f;
public ByteOrder f14310g;
public boolean f14311h;
public boolean f14312i;
public int f14313j;
public int f14314k;
public byte[] f14315l;
public int f14316m;
public int f14317n;
public int f14318o;
public int f14319p;
public int f14320q;
public boolean r;
public static final boolean f14296s = Log.isLoggable("ExifInterface", 3);
public static final List<Integer> f14297t = Arrays.asList(1, 6, 3, 8);
public static final List<Integer> f14298u = Arrays.asList(2, 7, 4, 5);
public static final int[] f14299v = {8, 8, 8};
public static final int[] f14300w = {8};
public static final byte[] f14301x = {-1, -40, -1};
public static final byte[] f14302y = {102, 116, 121, 112};
public static final byte[] f14303z = {109, 105, 102, 49};
public static final byte[] A = {104, 101, 105, 99};
public static final byte[] B = {79, 76, 89, 77, 80, 0};
public static final byte[] C = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
public static final byte[] D = {-119, 80, 78, 71, 13, 10, 26, 10};
public static final byte[] E = {101, 88, 73, 102};
public static final byte[] F = {73, 72, 68, 82};
public static final byte[] G = {73, 69, 78, 68};
public static final byte[] H = {82, 73, 70, 70};
public static final byte[] I = {87, 69, 66, 80};
public static final byte[] J = {69, 88, 73, 70};
public static final byte[] K = {-99, 1, 42};
public static final byte[] L = "VP8X".getBytes(Charset.defaultCharset());
public static final byte[] M = "VP8L".getBytes(Charset.defaultCharset());
public static final byte[] N = "VP8 ".getBytes(Charset.defaultCharset());
public static final byte[] O = "ANIM".getBytes(Charset.defaultCharset());
public static final byte[] P = "ANMF".getBytes(Charset.defaultCharset());
public static final String[] R = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
public static final int[] S = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
public static final byte[] T = {65, 83, 67, 73, 73, 0, 0, 0};
public class C0256a extends MediaDataSource {
public long f14321i;
public final b f14322j;
public C0256a(b bVar) {
this.f14322j = bVar;
}
@Override
public final void close() {
}
@Override
public final long getSize() {
return -1L;
}
@Override
public final int readAt(long j10, byte[] bArr, int i2, int i10) {
if (i10 == 0) {
return 0;
}
if (j10 < 0) {
return -1;
}
try {
long j11 = this.f14321i;
if (j11 != j10) {
if (j11 >= 0 && j10 >= j11 + this.f14322j.available()) {
return -1;
}
this.f14322j.e(j10);
this.f14321i = j10;
}
if (i10 > this.f14322j.available()) {
i10 = this.f14322j.available();
}
int read = this.f14322j.read(bArr, i2, i10);
if (read >= 0) {
this.f14321i += read;
return read;
}
} catch (IOException unused) {
}
this.f14321i = -1L;
return -1;
}
}
public static class c extends FilterOutputStream {
public final OutputStream f14329i;
public ByteOrder f14330j;
public c(OutputStream outputStream, ByteOrder byteOrder) {
super(outputStream);
this.f14329i = outputStream;
this.f14330j = byteOrder;
}
public final void a(int i2) {
this.f14329i.write(i2);
}
public final void e(int i2) {
ByteOrder byteOrder = this.f14330j;
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
this.f14329i.write((i2 >>> 0) & 255);
this.f14329i.write((i2 >>> 8) & 255);
this.f14329i.write((i2 >>> 16) & 255);
this.f14329i.write((i2 >>> 24) & 255);
} else if (byteOrder == ByteOrder.BIG_ENDIAN) {
this.f14329i.write((i2 >>> 24) & 255);
this.f14329i.write((i2 >>> 16) & 255);
this.f14329i.write((i2 >>> 8) & 255);
this.f14329i.write((i2 >>> 0) & 255);
}
}
public final void f(short s10) {
ByteOrder byteOrder = this.f14330j;
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
this.f14329i.write((s10 >>> 0) & 255);
this.f14329i.write((s10 >>> 8) & 255);
} else if (byteOrder == ByteOrder.BIG_ENDIAN) {
this.f14329i.write((s10 >>> 8) & 255);
this.f14329i.write((s10 >>> 0) & 255);
}
}
@Override
public final void write(byte[] bArr) {
this.f14329i.write(bArr);
}
@Override
public final void write(byte[] bArr, int i2, int i10) {
this.f14329i.write(bArr, i2, i10);
}
}
public static class d {
public final int f14331a;
public final int f14332b;
public final long f14333c;
public final byte[] f14334d;
public d(int i2, int i10, byte[] bArr) {
this(i2, i10, -1L, bArr);
}
public static d a(String str) {
byte[] bytes = (str + (char) 0).getBytes(a.f14292d0);
return new d(2, bytes.length, bytes);
}
public static d b(long j10, ByteOrder byteOrder) {
return c(new long[]{j10}, byteOrder);
}
public static d c(long[] jArr, ByteOrder byteOrder) {
ByteBuffer wrap = ByteBuffer.wrap(new byte[a.S[4] * jArr.length]);
wrap.order(byteOrder);
for (long j10 : jArr) {
wrap.putInt((int) j10);
}
return new d(4, jArr.length, wrap.array());
}
public static d d(g[] gVarArr, ByteOrder byteOrder) {
ByteBuffer wrap = ByteBuffer.wrap(new byte[a.S[5] * gVarArr.length]);
wrap.order(byteOrder);
for (g gVar : gVarArr) {
wrap.putInt((int) gVar.f14339a);
wrap.putInt((int) gVar.f14340b);
}
return new d(5, gVarArr.length, wrap.array());
}
public static d e(int i2, ByteOrder byteOrder) {
return f(new int[]{i2}, byteOrder);
}
public static d f(int[] iArr, ByteOrder byteOrder) {
ByteBuffer wrap = ByteBuffer.wrap(new byte[a.S[3] * iArr.length]);
wrap.order(byteOrder);
for (int i2 : iArr) {
wrap.putShort((short) i2);
}
return new d(3, iArr.length, wrap.array());
}
public final double g(ByteOrder byteOrder) {
Object j10 = j(byteOrder);
if (j10 != null) {
if (j10 instanceof String) {
return Double.parseDouble((String) j10);
}
if (j10 instanceof long[]) {
long[] jArr = (long[]) j10;
if (jArr.length == 1) {
return jArr[0];
}
throw new NumberFormatException("There are more than one component");
} else if (j10 instanceof int[]) {
int[] iArr = (int[]) j10;
if (iArr.length == 1) {
return iArr[0];
}
throw new NumberFormatException("There are more than one component");
} else if (j10 instanceof double[]) {
double[] dArr = (double[]) j10;
if (dArr.length == 1) {
return dArr[0];
}
throw new NumberFormatException("There are more than one component");
} else if (j10 instanceof g[]) {
g[] gVarArr = (g[]) j10;
if (gVarArr.length == 1) {
g gVar = gVarArr[0];
return gVar.f14339a / gVar.f14340b;
}
throw new NumberFormatException("There are more than one component");
} else {
throw new NumberFormatException("Couldn't find a double value");
}
}
throw new NumberFormatException("NULL can't be converted to a double value");
}
public final int h(ByteOrder byteOrder) {
Object j10 = j(byteOrder);
if (j10 != null) {
if (j10 instanceof String) {
return Integer.parseInt((String) j10);
}
if (j10 instanceof long[]) {
long[] jArr = (long[]) j10;
if (jArr.length == 1) {
return (int) jArr[0];
}
throw new NumberFormatException("There are more than one component");
} else if (j10 instanceof int[]) {
int[] iArr = (int[]) j10;
if (iArr.length == 1) {
return iArr[0];
}
throw new NumberFormatException("There are more than one component");
} else {
throw new NumberFormatException("Couldn't find a integer value");
}
}
throw new NumberFormatException("NULL can't be converted to a integer value");
}
public final String i(ByteOrder byteOrder) {
Object j10 = j(byteOrder);
if (j10 == null) {
return null;
}
if (j10 instanceof String) {
return (String) j10;
}
StringBuilder sb2 = new StringBuilder();
int i2 = 0;
if (j10 instanceof long[]) {
long[] jArr = (long[]) j10;
while (i2 < jArr.length) {
sb2.append(jArr[i2]);
i2++;
if (i2 != jArr.length) {
sb2.append(",");
}
}
return sb2.toString();
} else if (j10 instanceof int[]) {
int[] iArr = (int[]) j10;
while (i2 < iArr.length) {
sb2.append(iArr[i2]);
i2++;
if (i2 != iArr.length) {
sb2.append(",");
}
}
return sb2.toString();
} else if (j10 instanceof double[]) {
double[] dArr = (double[]) j10;
while (i2 < dArr.length) {
sb2.append(dArr[i2]);
i2++;
if (i2 != dArr.length) {
sb2.append(",");
}
}
return sb2.toString();
} else if (j10 instanceof g[]) {
g[] gVarArr = (g[]) j10;
while (i2 < gVarArr.length) {
sb2.append(gVarArr[i2].f14339a);
sb2.append('/');
sb2.append(gVarArr[i2].f14340b);
i2++;
if (i2 != gVarArr.length) {
sb2.append(",");
}
}
return sb2.toString();
} else {
return null;
}
}
public final Object j(ByteOrder byteOrder) {
b bVar;
byte b10;
byte[] bArr;
b bVar2 = null;
try {
bVar = new b(this.f14334d);
try {
bVar.f14326j = byteOrder;
boolean z10 = true;
int i2 = 0;
switch (this.f14331a) {
case 1:
case 6:
byte[] bArr2 = this.f14334d;
if (bArr2.length == 1 && bArr2[0] >= 0 && bArr2[0] <= 1) {
String str = new String(new char[]{(char) (bArr2[0] + 48)});
try {
bVar.close();
} catch (IOException unused) {
}
return str;
}
String str2 = new String(bArr2, a.f14292d0);
try {
bVar.close();
} catch (IOException unused2) {
}
return str2;
case 2:
case 7:
if (this.f14332b >= a.T.length) {
int i10 = 0;
while (true) {
bArr = a.T;
if (i10 < bArr.length) {
if (this.f14334d[i10] != bArr[i10]) {
z10 = false;
} else {
i10++;
}
}
}
if (z10) {
i2 = bArr.length;
}
}
StringBuilder sb2 = new StringBuilder();
while (i2 < this.f14332b && (b10 = this.f14334d[i2]) != 0) {
if (b10 >= 32) {
sb2.append((char) b10);
} else {
sb2.append('?');
}
i2++;
}
String sb3 = sb2.toString();
try {
bVar.close();
} catch (IOException unused3) {
}
return sb3;
case 3:
int[] iArr = new int[this.f14332b];
while (i2 < this.f14332b) {
iArr[i2] = bVar.readUnsignedShort();
i2++;
}
try {
bVar.close();
} catch (IOException unused4) {
}
return iArr;
case 4:
long[] jArr = new long[this.f14332b];
while (i2 < this.f14332b) {
jArr[i2] = bVar.a();
i2++;
}
try {
bVar.close();
} catch (IOException unused5) {
}
return jArr;
case 5:
g[] gVarArr = new g[this.f14332b];
while (i2 < this.f14332b) {
gVarArr[i2] = new g(bVar.a(), bVar.a());
i2++;
}
try {
bVar.close();
} catch (IOException unused6) {
}
return gVarArr;
case 8:
int[] iArr2 = new int[this.f14332b];
while (i2 < this.f14332b) {
iArr2[i2] = bVar.readShort();
i2++;
}
try {
bVar.close();
} catch (IOException unused7) {
}
return iArr2;
case 9:
int[] iArr3 = new int[this.f14332b];
while (i2 < this.f14332b) {
iArr3[i2] = bVar.readInt();
i2++;
}
try {
bVar.close();
} catch (IOException unused8) {
}
return iArr3;
case 10:
g[] gVarArr2 = new g[this.f14332b];
while (i2 < this.f14332b) {
gVarArr2[i2] = new g(bVar.readInt(), bVar.readInt());
i2++;
}
try {
bVar.close();
} catch (IOException unused9) {
}
return gVarArr2;
case 11:
double[] dArr = new double[this.f14332b];
while (i2 < this.f14332b) {
dArr[i2] = bVar.readFloat();
i2++;
}
try {
bVar.close();
} catch (IOException unused10) {
}
return dArr;
case 12:
double[] dArr2 = new double[this.f14332b];
while (i2 < this.f14332b) {
dArr2[i2] = bVar.readDouble();
i2++;
}
try {
bVar.close();
} catch (IOException unused11) {
}
return dArr2;
default:
try {
bVar.close();
} catch (IOException unused12) {
}
return null;
}
} catch (IOException unused13) {
if (bVar != null) {
try {
bVar.close();
} catch (IOException unused14) {
}
}
return null;
} catch (Throwable th) {
th = th;
bVar2 = bVar;
if (bVar2 != null) {
try {
bVar2.close();
} catch (IOException unused15) {
}
}
throw th;
}
} catch (IOException unused16) {
bVar = null;
} catch (Throwable th2) {
th = th2;
}
}
public final String toString() {
StringBuilder r = j.r("(");
r.append(a.R[this.f14331a]);
r.append(", data length:");
return o.c(r, this.f14334d.length, ")");
}
public d(int i2, int i10, long j10, byte[] bArr) {
this.f14331a = i2;
this.f14332b = i10;
this.f14333c = j10;
this.f14334d = bArr;
}
}
public static class f {
public static void a(FileDescriptor fileDescriptor, int i2) {
try {
Os.lseek(fileDescriptor, 0, i2);
} catch (ErrnoException e10) {
throw new IOException("Failed to seek file descriptor", e10);
}
}
}
public static class g {
public final long f14339a;
public final long f14340b;
public g(double d10) {
this((long) (d10 * 10000.0d), 10000L);
}
public final String toString() {
return this.f14339a + "/" + this.f14340b;
}
public g(long j10, long j11) {
if (j11 == 0) {
this.f14339a = 0L;
this.f14340b = 1L;
return;
}
this.f14339a = j10;
this.f14340b = j11;
}
}
static {
e[] eVarArr;
e[] eVarArr2 = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e("ImageWidth", 256), new e("ImageLength", 257), new e("BitsPerSample", CustomCameraView.BUTTON_STATE_ONLY_RECORDER, 3), new e("Compression", CustomCameraView.BUTTON_STATE_BOTH, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", SubsamplingScaleImageView.ORIENTATION_270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273), new e("Orientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278), new e("StripByteCounts", 279), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("SensorTopBorder", 4, 4), new e("SensorLeftBorder", 5, 4), new e("SensorBottomBorder", 6, 4), new e("SensorRightBorder", 7, 4), new e("ISO", 23, 3), new e("JpgFromRaw", 46, 7), new e("Xmp", 700, 1)};
e[] eVarArr3 = {new e("ExposureTime", 33434, 5), new e("FNumber", 33437, 5), new e("ExposureProgram", 34850, 3), new e("SpectralSensitivity", 34852, 2), new e("PhotographicSensitivity", 34855, 3), new e("OECF", 34856, 7), new e("SensitivityType", 34864, 3), new e("StandardOutputSensitivity", 34865, 4), new e("RecommendedExposureIndex", 34866, 4), new e("ISOSpeed", 34867, 4), new e("ISOSpeedLatitudeyyy", 34868, 4), new e("ISOSpeedLatitudezzz", 34869, 4), new e("ExifVersion", 36864, 2), new e("DateTimeOriginal", 36867, 2), new e("DateTimeDigitized", 36868, 2), new e("OffsetTime", 36880, 2), new e("OffsetTimeOriginal", 36881, 2), new e("OffsetTimeDigitized", 36882, 2), new e("ComponentsConfiguration", 37121, 7), new e("CompressedBitsPerPixel", 37122, 5), new e("ShutterSpeedValue", 37377, 10), new e("ApertureValue", 37378, 5), new e("BrightnessValue", 37379, 10), new e("ExposureBiasValue", 37380, 10), new e("MaxApertureValue", 37381, 5), new e("SubjectDistance", 37382, 5), new e("MeteringMode", 37383, 3), new e("LightSource", 37384, 3), new e("Flash", 37385, 3), new e("FocalLength", 37386, 5), new e("SubjectArea", 37396, 3), new e("MakerNote", 37500, 7), new e("UserComment", 37510, 7), new e("SubSecTime", 37520, 2), new e("SubSecTimeOriginal", 37521, 2), new e("SubSecTimeDigitized", 37522, 2), new e("FlashpixVersion", 40960, 7), new e("ColorSpace", 40961, 3), new e("PixelXDimension", 40962), new e("PixelYDimension", 40963), new e("RelatedSoundFile", 40964, 2), new e("InteroperabilityIFDPointer", 40965, 4), new e("FlashEnergy", 41483, 5), new e("SpatialFrequencyResponse", 41484, 7), new e("FocalPlaneXResolution", 41486, 5), new e("FocalPlaneYResolution", 41487, 5), new e("FocalPlaneResolutionUnit", 41488, 3), new e("SubjectLocation", 41492, 3), new e("ExposureIndex", 41493, 5), new e("SensingMethod", 41495, 3), new e("FileSource", 41728, 7), new e("SceneType", 41729, 7), new e("CFAPattern", 41730, 7), new e("CustomRendered", 41985, 3), new e("ExposureMode", 41986, 3), new e("WhiteBalance", 41987, 3), new e("DigitalZoomRatio", 41988, 5), new e("FocalLengthIn35mmFilm", 41989, 3), new e("SceneCaptureType", 41990, 3), new e("GainControl", 41991, 3), new e("Contrast", 41992, 3), new e("Saturation", 41993, 3), new e("Sharpness", 41994, 3), new e("DeviceSettingDescription", 41995, 7), new e("SubjectDistanceRange", 41996, 3), new e("ImageUniqueID", 42016, 2), new e("CameraOwnerName", 42032, 2), new e("BodySerialNumber", 42033, 2), new e("LensSpecification", 42034, 5), new e("LensMake", 42035, 2), new e("LensModel", 42036, 2), new e("Gamma", 42240, 5), new e("DNGVersion", 50706, 1), new e("DefaultCropSize", 50720)};
e[] eVarArr4 = {new e("GPSVersionID", 0, 1), new e("GPSLatitudeRef", 1, 2), new e("GPSLatitude", 2, 5), new e("GPSLongitudeRef", 3, 2), new e("GPSLongitude", 4, 5), new e("GPSAltitudeRef", 5, 1), new e("GPSAltitude", 6, 5), new e("GPSTimeStamp", 7, 5), new e("GPSSatellites", 8, 2), new e("GPSStatus", 9, 2), new e("GPSMeasureMode", 10, 2), new e("GPSDOP", 11, 5), new e("GPSSpeedRef", 12, 2), new e("GPSSpeed", 13, 5), new e("GPSTrackRef", 14, 2), new e("GPSTrack", 15, 5), new e("GPSImgDirectionRef", 16, 2), new e("GPSImgDirection", 17, 5), new e("GPSMapDatum", 18, 2), new e("GPSDestLatitudeRef", 19, 2), new e("GPSDestLatitude", 20, 5), new e("GPSDestLongitudeRef", 21, 2), new e("GPSDestLongitude", 22, 5), new e("GPSDestBearingRef", 23, 2), new e("GPSDestBearing", 24, 5), new e("GPSDestDistanceRef", 25, 2), new e("GPSDestDistance", 26, 5), new e("GPSProcessingMethod", 27, 7), new e("GPSAreaInformation", 28, 7), new e("GPSDateStamp", 29, 2), new e("GPSDifferential", 30, 3), new e("GPSHPositioningError", 31, 5)};
e[] eVarArr5 = {new e("InteroperabilityIndex", 1, 2)};
e[] eVarArr6 = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e("ThumbnailImageWidth", 256), new e("ThumbnailImageLength", 257), new e("BitsPerSample", CustomCameraView.BUTTON_STATE_ONLY_RECORDER, 3), new e("Compression", CustomCameraView.BUTTON_STATE_BOTH, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", SubsamplingScaleImageView.ORIENTATION_270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273), new e("ThumbnailOrientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278), new e("StripByteCounts", 279), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("DNGVersion", 50706, 1), new e("DefaultCropSize", 50720)};
U = new e("StripOffsets", 273, 3);
V = new e[][]{eVarArr2, eVarArr3, eVarArr4, eVarArr5, eVarArr6, eVarArr2, new e[]{new e("ThumbnailImage", 256, 7), new e("CameraSettingsIFDPointer", 8224, 4), new e("ImageProcessingIFDPointer", 8256, 4)}, new e[]{new e("PreviewImageStart", 257, 4), new e("PreviewImageLength", CustomCameraView.BUTTON_STATE_ONLY_RECORDER, 4)}, new e[]{new e("AspectFrame", 4371, 3)}, new e[]{new e("ColorSpace", 55, 3)}};
W = new e[]{new e("SubIFDPointer", 330, 4), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("InteroperabilityIFDPointer", 40965, 4), new e("CameraSettingsIFDPointer", 8224, 1), new e("ImageProcessingIFDPointer", 8256, 1)};
X = new e("JPEGInterchangeFormat", 513, 4);
Y = new e("JPEGInterchangeFormatLength", 514, 4);
Z = new HashMap[10];
f14289a0 = new HashMap[10];
f14290b0 = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
f14291c0 = new HashMap<>();
Charset forName = Charset.forName("US-ASCII");
f14292d0 = forName;
f14293e0 = "Exif\u0000\u0000".getBytes(forName);
f14294f0 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US);
Q = simpleDateFormat;
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(UtcDates.UTC));
int i2 = 0;
while (true) {
e[][] eVarArr7 = V;
if (i2 < eVarArr7.length) {
Z[i2] = new HashMap<>();
f14289a0[i2] = new HashMap<>();
for (e eVar : eVarArr7[i2]) {
Z[i2].put(Integer.valueOf(eVar.f14335a), eVar);
f14289a0[i2].put(eVar.f14336b, eVar);
}
i2++;
} else {
HashMap<Integer, Integer> hashMap = f14291c0;
e[] eVarArr8 = W;
hashMap.put(Integer.valueOf(eVarArr8[0].f14335a), 5);
hashMap.put(Integer.valueOf(eVarArr8[1].f14335a), 1);
hashMap.put(Integer.valueOf(eVarArr8[2].f14335a), 2);
hashMap.put(Integer.valueOf(eVarArr8[3].f14335a), 3);
hashMap.put(Integer.valueOf(eVarArr8[4].f14335a), 7);
hashMap.put(Integer.valueOf(eVarArr8[5].f14335a), 8);
Pattern.compile(".*[1-9].*");
f14295g0 = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
return;
}
}
}
public a(String str) {
FileInputStream fileInputStream;
e[][] eVarArr = V;
this.f14308e = new HashMap[eVarArr.length];
this.f14309f = new HashSet(eVarArr.length);
this.f14310g = ByteOrder.BIG_ENDIAN;
Objects.requireNonNull(str, "filename cannot be null");
FileInputStream fileInputStream2 = null;
this.f14306c = null;
this.f14304a = str;
try {
fileInputStream = new FileInputStream(str);
} catch (Throwable th) {
th = th;
}
try {
if (y(fileInputStream.getFD())) {
this.f14305b = fileInputStream.getFD();
} else {
this.f14305b = null;
}
A(fileInputStream);
c(fileInputStream);
} catch (Throwable th2) {
th = th2;
fileInputStream2 = fileInputStream;
c(fileInputStream2);
throw th;
}
}
public static boolean N(byte[] bArr, byte[] bArr2) {
if (bArr2 != null && bArr.length >= bArr2.length) {
for (int i2 = 0; i2 < bArr2.length; i2++) {
if (bArr[i2] != bArr2[i2]) {
return false;
}
}
return true;
}
return false;
}
public static String b(byte[] bArr) {
StringBuilder sb2 = new StringBuilder(bArr.length * 2);
for (int i2 = 0; i2 < bArr.length; i2++) {
sb2.append(String.format("%02x", Byte.valueOf(bArr[i2])));
}
return sb2.toString();
}
public static void c(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException e10) {
throw e10;
} catch (Exception unused) {
}
}
}
public static double d(String str, String str2) {
try {
String[] split = str.split(",", -1);
String[] split2 = split[0].split("/", -1);
double parseDouble = Double.parseDouble(split2[0].trim()) / Double.parseDouble(split2[1].trim());
String[] split3 = split[1].split("/", -1);
String[] split4 = split[2].split("/", -1);
double parseDouble2 = ((Double.parseDouble(split4[0].trim()) / Double.parseDouble(split4[1].trim())) / 3600.0d) + ((Double.parseDouble(split3[0].trim()) / Double.parseDouble(split3[1].trim())) / 60.0d) + parseDouble;
if (!str2.equals("S") && !str2.equals("W")) {
if (!str2.equals("N") && !str2.equals("E")) {
throw new IllegalArgumentException();
}
return parseDouble2;
}
return -parseDouble2;
} catch (ArrayIndexOutOfBoundsException | NumberFormatException unused) {
throw new IllegalArgumentException();
}
}
public static long[] e(Object obj) {
if (obj instanceof int[]) {
int[] iArr = (int[]) obj;
long[] jArr = new long[iArr.length];
for (int i2 = 0; i2 < iArr.length; i2++) {
jArr[i2] = iArr[i2];
}
return jArr;
} else if (obj instanceof long[]) {
return (long[]) obj;
} else {
return null;
}
}
public static int f(InputStream inputStream, OutputStream outputStream) {
byte[] bArr = new byte[8192];
int i2 = 0;
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
return i2;
}
i2 += read;
outputStream.write(bArr, 0, read);
}
}
public static void g(InputStream inputStream, OutputStream outputStream, int i2) {
byte[] bArr = new byte[8192];
while (i2 > 0) {
int min = Math.min(i2, 8192);
int read = inputStream.read(bArr, 0, min);
if (read == min) {
i2 -= read;
outputStream.write(bArr, 0, read);
} else {
throw new IOException("Failed to copy the given amount of bytes from the inputstream to the output stream.");
}
}
}
public static Pair<Integer, Integer> w(String str) {
if (str.contains(",")) {
String[] split = str.split(",", -1);
Pair<Integer, Integer> w4 = w(split[0]);
if (((Integer) w4.first).intValue() == 2) {
return w4;
}
for (int i2 = 1; i2 < split.length; i2++) {
Pair<Integer, Integer> w10 = w(split[i2]);
int intValue = (((Integer) w10.first).equals(w4.first) || ((Integer) w10.second).equals(w4.first)) ? ((Integer) w4.first).intValue() : -1;
int intValue2 = (((Integer) w4.second).intValue() == -1 || !(((Integer) w10.first).equals(w4.second) || ((Integer) w10.second).equals(w4.second))) ? -1 : ((Integer) w4.second).intValue();
if (intValue == -1 && intValue2 == -1) {
return new Pair<>(2, -1);
}
if (intValue == -1) {
w4 = new Pair<>(Integer.valueOf(intValue2), -1);
} else if (intValue2 == -1) {
w4 = new Pair<>(Integer.valueOf(intValue), -1);
}
}
return w4;
} else if (str.contains("/")) {
String[] split2 = str.split("/", -1);
if (split2.length == 2) {
try {
long parseDouble = (long) Double.parseDouble(split2[0]);
long parseDouble2 = (long) Double.parseDouble(split2[1]);
if (parseDouble >= 0 && parseDouble2 >= 0) {
if (parseDouble <= 2147483647L && parseDouble2 <= 2147483647L) {
return new Pair<>(10, 5);
}
return new Pair<>(5, -1);
}
return new Pair<>(10, -1);
} catch (NumberFormatException unused) {
}
}
return new Pair<>(2, -1);
} else {
try {
try {
Long valueOf = Long.valueOf(Long.parseLong(str));
if (valueOf.longValue() >= 0 && valueOf.longValue() <= 65535) {
return new Pair<>(3, 4);
}
if (valueOf.longValue() < 0) {
return new Pair<>(9, -1);
}
return new Pair<>(4, -1);
} catch (NumberFormatException unused2) {
return new Pair<>(2, -1);
}
} catch (NumberFormatException unused3) {
Double.parseDouble(str);
return new Pair<>(12, -1);
}
}
}
public static boolean y(FileDescriptor fileDescriptor) {
try {
f.a(fileDescriptor, OsConstants.SEEK_CUR);
return true;
} catch (Exception unused) {
return false;
}
}
public final void A(InputStream inputStream) {
Objects.requireNonNull(inputStream, "inputstream shouldn't be null");
for (int i2 = 0; i2 < V.length; i2++) {
try {
try {
this.f14308e[i2] = new HashMap<>();
} catch (IOException unused) {
boolean z10 = f14296s;
a();
if (!z10) {
return;
}
}
} finally {
a();
if (f14296s) {
C();
}
}
}
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
this.f14307d = o(bufferedInputStream);
b bVar = new b(bufferedInputStream, ByteOrder.BIG_ENDIAN);
switch (this.f14307d) {
case 0:
case 1:
case 2:
case 3:
case 5:
case 6:
case 8:
case 11:
s(bVar);
break;
case 4:
n(bVar, 0, 0);
a();
if (f14296s) {
C();
return;
}
return;
case 7:
p(bVar);
break;
case 9:
r(bVar);
a();
if (f14296s) {
C();
return;
}
return;
case 10:
t(bVar);
a();
if (f14296s) {
C();
return;
}
return;
case 12:
m(bVar);
break;
case 13:
q(bVar);
a();
if (f14296s) {
C();
return;
}
return;
case 14:
v(bVar);
a();
if (f14296s) {
C();
return;
}
return;
}
bVar.e(this.f14317n);
M(bVar);
}
public final void B(b bVar, int i2) {
ByteOrder D2 = D(bVar);
this.f14310g = D2;
bVar.f14326j = D2;
int readUnsignedShort = bVar.readUnsignedShort();
int i10 = this.f14307d;
if (i10 != 7 && i10 != 10 && readUnsignedShort != 42) {
StringBuilder r = j.r("Invalid start code: ");
r.append(Integer.toHexString(readUnsignedShort));
throw new IOException(r.toString());
}
int readInt = bVar.readInt();
if (readInt >= 8 && readInt < i2) {
int i11 = readInt - 8;
if (i11 > 0 && bVar.skipBytes(i11) != i11) {
throw new IOException(j.i("Couldn't jump to first Ifd: ", i11));
}
return;
}
throw new IOException(j.i("Invalid first Ifd offset: ", readInt));
}
public final void C() {
for (int i2 = 0; i2 < this.f14308e.length; i2++) {
this.f14308e[i2].size();
for (Map.Entry<String, d> entry : this.f14308e[i2].entrySet()) {
d value = entry.getValue();
entry.getKey();
value.toString();
value.i(this.f14310g);
}
}
}
public final ByteOrder D(b bVar) {
short readShort = bVar.readShort();
if (readShort != 18761) {
if (readShort == 19789) {
return ByteOrder.BIG_ENDIAN;
}
StringBuilder r = j.r("Invalid byte order: ");
r.append(Integer.toHexString(readShort));
throw new IOException(r.toString());
}
return ByteOrder.LITTLE_ENDIAN;
}
public final void E(byte[] bArr, int i2) {
b bVar = new b(bArr);
B(bVar, bArr.length);
F(bVar, i2);
}
public final void F(b bVar, int i2) {
short s10;
long j10;
boolean z10;
int i10;
short s11;
String str;
e eVar;
short s12;
boolean z11;
int i11;
int readUnsignedShort;
long j11;
this.f14309f.add(Integer.valueOf(bVar.f14328l));
if (bVar.f14328l + 2 > bVar.f14327k) {
return;
}
short readShort = bVar.readShort();
if ((readShort * 12) + bVar.f14328l > bVar.f14327k || readShort <= 0) {
return;
}
char c10 = 0;
short s13 = 0;
while (s13 < readShort) {
int readUnsignedShort2 = bVar.readUnsignedShort();
int readUnsignedShort3 = bVar.readUnsignedShort();
int readInt = bVar.readInt();
long j12 = bVar.f14328l + 4;
e eVar2 = Z[i2].get(Integer.valueOf(readUnsignedShort2));
boolean z12 = f14296s;
if (z12) {
Object[] objArr = new Object[5];
objArr[c10] = Integer.valueOf(i2);
objArr[1] = Integer.valueOf(readUnsignedShort2);
objArr[2] = eVar2 != null ? eVar2.f14336b : null;
objArr[3] = Integer.valueOf(readUnsignedShort3);
objArr[4] = Integer.valueOf(readInt);
String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr);
}
if (eVar2 != null && readUnsignedShort3 > 0) {
int[] iArr = S;
if (readUnsignedShort3 < iArr.length) {
int i12 = eVar2.f14337c;
if (i12 == 7 || readUnsignedShort3 == 7 || i12 == readUnsignedShort3 || (i10 = eVar2.f14338d) == readUnsignedShort3 || ((i12 == 4 || i10 == 4) && readUnsignedShort3 == 3) || (((i12 == 9 || i10 == 9) && readUnsignedShort3 == 8) || ((i12 == 12 || i10 == 12) && readUnsignedShort3 == 11))) {
if (readUnsignedShort3 == 7) {
readUnsignedShort3 = i12;
}
int i13 = iArr[readUnsignedShort3];
s10 = s13;
j10 = readInt * i13;
if (j10 >= 0 && j10 <= 2147483647L) {
z10 = true;
if (!z10) {
bVar.e(j12);
s11 = readShort;
s12 = s10;
} else {
if (j10 > 4) {
int readInt2 = bVar.readInt();
s11 = readShort;
s12 = s10;
if (this.f14307d == 7) {
if ("MakerNote".equals(eVar2.f14336b)) {
this.f14318o = readInt2;
} else if (i2 == 6 && "ThumbnailImage".equals(eVar2.f14336b)) {
this.f14319p = readInt2;
this.f14320q = readInt;
d e10 = d.e(6, this.f14310g);
eVar = eVar2;
i11 = readInt;
d b10 = d.b(this.f14319p, this.f14310g);
z11 = z12;
d b11 = d.b(this.f14320q, this.f14310g);
this.f14308e[4].put("Compression", e10);
this.f14308e[4].put("JPEGInterchangeFormat", b10);
this.f14308e[4].put("JPEGInterchangeFormatLength", b11);
j11 = readInt2;
str = "Compression";
if (j11 + j10 > bVar.f14327k) {
bVar.e(j11);
} else {
bVar.e(j12);
}
}
}
eVar = eVar2;
z11 = z12;
i11 = readInt;
j11 = readInt2;
str = "Compression";
if (j11 + j10 > bVar.f14327k) {
}
} else {
s11 = readShort;
str = "Compression";
eVar = eVar2;
s12 = s10;
z11 = z12;
i11 = readInt;
}
Integer num = f14291c0.get(Integer.valueOf(readUnsignedShort2));
if (num != null) {
long j13 = -1;
if (readUnsignedShort3 == 3) {
readUnsignedShort = bVar.readUnsignedShort();
} else {
if (readUnsignedShort3 == 4) {
j13 = bVar.a();
} else if (readUnsignedShort3 == 8) {
readUnsignedShort = bVar.readShort();
} else if (readUnsignedShort3 == 9 || readUnsignedShort3 == 13) {
readUnsignedShort = bVar.readInt();
}
if (z11) {
String.format("Offset: %d, tagName: %s", Long.valueOf(j13), eVar.f14336b);
}
if (j13 > 0 && j13 < bVar.f14327k && !this.f14309f.contains(Integer.valueOf((int) j13))) {
bVar.e(j13);
F(bVar, num.intValue());
}
bVar.e(j12);
}
j13 = readUnsignedShort;
if (z11) {
}
if (j13 > 0) {
bVar.e(j13);
F(bVar, num.intValue());
}
bVar.e(j12);
} else {
e eVar3 = eVar;
byte[] bArr = new byte[(int) j10];
bVar.readFully(bArr);
d dVar = new d(readUnsignedShort3, i11, bVar.f14328l + this.f14317n, bArr);
this.f14308e[i2].put(eVar3.f14336b, dVar);
if ("DNGVersion".equals(eVar3.f14336b)) {
this.f14307d = 3;
}
if ((("Make".equals(eVar3.f14336b) || "Model".equals(eVar3.f14336b)) && dVar.i(this.f14310g).contains("PENTAX")) || (str.equals(eVar3.f14336b) && dVar.h(this.f14310g) == 65535)) {
this.f14307d = 8;
}
if (bVar.f14328l != j12) {
bVar.e(j12);
}
}
s13 = (short) (s12 + 1);
readShort = s11;
c10 = 0;
}
s13 = (short) (s12 + 1);
readShort = s11;
c10 = 0;
}
z10 = false;
if (!z10) {
}
s13 = (short) (s12 + 1);
readShort = s11;
c10 = 0;
} else if (z12) {
String str2 = R[readUnsignedShort3];
}
}
}
s10 = s13;
j10 = 0;
z10 = false;
if (!z10) {
}
s13 = (short) (s12 + 1);
readShort = s11;
c10 = 0;
}
if (bVar.f14328l + 4 <= bVar.f14327k) {
int readInt3 = bVar.readInt();
if (f14296s) {
String.format("nextIfdOffset: %d", Integer.valueOf(readInt3));
}
long j14 = readInt3;
if (j14 <= 0 || readInt3 >= bVar.f14327k || this.f14309f.contains(Integer.valueOf(readInt3))) {
return;
}
bVar.e(j14);
if (this.f14308e[4].isEmpty()) {
F(bVar, 4);
} else if (this.f14308e[5].isEmpty()) {
F(bVar, 5);
}
}
}
public final void G(String str) {
for (int i2 = 0; i2 < V.length; i2++) {
this.f14308e[i2].remove(str);
}
}
public final void H() {
InputStream inputStream;
FileInputStream fileInputStream;
InputStream inputStream2;
FileOutputStream fileOutputStream;
BufferedInputStream bufferedInputStream;
OutputStream bufferedOutputStream;
int i2 = this.f14307d;
if (i2 == 4 || i2 == 13 || i2 == 14) {
if (this.f14305b == null && this.f14304a == null) {
throw new IOException("ExifInterface does not support saving attributes for the current input.");
}
int i10 = this.f14316m;
BufferedInputStream bufferedInputStream2 = null;
this.f14315l = (i10 == 6 || i10 == 7) ? u() : null;
try {
File createTempFile = File.createTempFile("temp", "tmp");
if (this.f14304a != null) {
fileInputStream = new FileInputStream(this.f14304a);
} else {
FileDescriptor fileDescriptor = this.f14305b;
if (fileDescriptor != null) {
f.a(fileDescriptor, OsConstants.SEEK_SET);
fileInputStream = new FileInputStream(this.f14305b);
} else {
fileInputStream = null;
}
}
try {
?? fileOutputStream2 = new FileOutputStream(createTempFile);
try {
f(fileInputStream, fileOutputStream2);
c(fileInputStream);
c(fileOutputStream2);
try {
try {
FileInputStream fileInputStream2 = new FileInputStream(createTempFile);
if (this.f14304a != null) {
fileOutputStream = new FileOutputStream(this.f14304a);
} else {
FileDescriptor fileDescriptor2 = this.f14305b;
if (fileDescriptor2 != null) {
f.a(fileDescriptor2, OsConstants.SEEK_SET);
fileOutputStream = new FileOutputStream(this.f14305b);
} else {
fileOutputStream = null;
}
}
try {
bufferedInputStream = new BufferedInputStream(fileInputStream2);
try {
bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
} catch (Exception e10) {
e = e10;
} catch (Throwable th) {
th = th;
}
} catch (Exception e11) {
e = e11;
inputStream2 = null;
}
} catch (Exception e12) {
e = e12;
inputStream2 = null;
fileOutputStream = null;
}
} catch (Throwable th2) {
th = th2;
inputStream2 = null;
}
try {
int i11 = this.f14307d;
if (i11 == 4) {
I(bufferedInputStream, bufferedOutputStream);
} else if (i11 == 13) {
J(bufferedInputStream, bufferedOutputStream);
} else if (i11 == 14) {
K(bufferedInputStream, bufferedOutputStream);
}
c(bufferedInputStream);
c(bufferedOutputStream);
createTempFile.delete();
this.f14315l = null;
} catch (Exception e13) {
e = e13;
bufferedInputStream2 = bufferedOutputStream;
inputStream2 = bufferedInputStream2;
bufferedInputStream2 = bufferedInputStream;
try {
c(bufferedInputStream2);
c(inputStream2);
FileInputStream fileInputStream3 = new FileInputStream(createTempFile);
if (this.f14304a == null) {
FileDescriptor fileDescriptor3 = this.f14305b;
if (fileDescriptor3 != null) {
try {
f.a(fileDescriptor3, OsConstants.SEEK_SET);
fileOutputStream = new FileOutputStream(this.f14305b);
} catch (Exception e14) {
throw new IOException("Failed to save new file. Original file may be corrupted since error occurred while trying to restore it.", e14);
}
}
} else {
fileOutputStream = new FileOutputStream(this.f14304a);
}
f(fileInputStream3, fileOutputStream);
c(fileInputStream3);
c(fileOutputStream);
throw new IOException("Failed to save new file", e);
} catch (Throwable th3) {
th = th3;
c(bufferedInputStream2);
c(inputStream2);
createTempFile.delete();
throw th;
}
} catch (Throwable th4) {
th = th4;
bufferedInputStream2 = bufferedOutputStream;
inputStream2 = bufferedInputStream2;
bufferedInputStream2 = bufferedInputStream;
c(bufferedInputStream2);
c(inputStream2);
createTempFile.delete();
throw th;
}
} catch (Exception e15) {
e = e15;
bufferedInputStream2 = fileOutputStream2;
inputStream = bufferedInputStream2;
bufferedInputStream2 = fileInputStream;
try {
throw new IOException("Failed to copy original file to temp file", e);
} catch (Throwable th5) {
th = th5;
c(bufferedInputStream2);
c(inputStream);
throw th;
}
} catch (Throwable th6) {
th = th6;
bufferedInputStream2 = fileOutputStream2;
inputStream = bufferedInputStream2;
bufferedInputStream2 = fileInputStream;
c(bufferedInputStream2);
c(inputStream);
throw th;
}
} catch (Exception e16) {
e = e16;
} catch (Throwable th7) {
th = th7;
}
} catch (Exception e17) {
e = e17;
inputStream = null;
} catch (Throwable th8) {
th = th8;
inputStream = null;
}
} else {
throw new IOException("ExifInterface only supports saving attributes on JPEG, PNG, or WebP formats.");
}
}
public final void I(InputStream inputStream, OutputStream outputStream) {
if (f14296s) {
Objects.toString(inputStream);
Objects.toString(outputStream);
}
DataInputStream dataInputStream = new DataInputStream(inputStream);
c cVar = new c(outputStream, ByteOrder.BIG_ENDIAN);
if (dataInputStream.readByte() == -1) {
cVar.a(-1);
if (dataInputStream.readByte() == -40) {
cVar.a(-40);
d dVar = null;
if (j("Xmp") != null && this.r) {
dVar = this.f14308e[0].remove("Xmp");
}
cVar.a(-1);
cVar.a(-31);
R(cVar);
if (dVar != null) {
this.f14308e[0].put("Xmp", dVar);
}
byte[] bArr = new byte[4096];
while (dataInputStream.readByte() == -1) {
byte readByte = dataInputStream.readByte();
if (readByte == -39 || readByte == -38) {
cVar.a(-1);
cVar.a(readByte);
f(dataInputStream, cVar);
return;
} else if (readByte != -31) {
cVar.a(-1);
cVar.a(readByte);
int readUnsignedShort = dataInputStream.readUnsignedShort();
cVar.f((short) readUnsignedShort);
int i2 = readUnsignedShort - 2;
if (i2 < 0) {
throw new IOException("Invalid length");
}
while (i2 > 0) {
int read = dataInputStream.read(bArr, 0, Math.min(i2, 4096));
if (read >= 0) {
cVar.write(bArr, 0, read);
i2 -= read;
}
}
} else {
int readUnsignedShort2 = dataInputStream.readUnsignedShort() - 2;
if (readUnsignedShort2 >= 0) {
byte[] bArr2 = new byte[6];
if (readUnsignedShort2 >= 6) {
if (dataInputStream.read(bArr2) == 6) {
if (Arrays.equals(bArr2, f14293e0)) {
int i10 = readUnsignedShort2 - 6;
if (dataInputStream.skipBytes(i10) != i10) {
throw new IOException("Invalid length");
}
}
} else {
throw new IOException("Invalid exif");
}
}
cVar.a(-1);
cVar.a(readByte);
cVar.f((short) (readUnsignedShort2 + 2));
if (readUnsignedShort2 >= 6) {
readUnsignedShort2 -= 6;
cVar.write(bArr2);
}
while (readUnsignedShort2 > 0) {
int read2 = dataInputStream.read(bArr, 0, Math.min(readUnsignedShort2, 4096));
if (read2 >= 0) {
cVar.write(bArr, 0, read2);
readUnsignedShort2 -= read2;
}
}
} else {
throw new IOException("Invalid length");
}
}
}
throw new IOException("Invalid marker");
}
throw new IOException("Invalid marker");
}
throw new IOException("Invalid marker");
}
public final void J(InputStream inputStream, OutputStream outputStream) {
if (f14296s) {
Objects.toString(inputStream);
Objects.toString(outputStream);
}
DataInputStream dataInputStream = new DataInputStream(inputStream);
ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
c cVar = new c(outputStream, byteOrder);
byte[] bArr = D;
g(dataInputStream, cVar, bArr.length);
int i2 = this.f14317n;
if (i2 == 0) {
int readInt = dataInputStream.readInt();
cVar.e(readInt);
g(dataInputStream, cVar, readInt + 4 + 4);
} else {
g(dataInputStream, cVar, ((i2 - bArr.length) - 4) - 4);
dataInputStream.skipBytes(dataInputStream.readInt() + 4 + 4);
}
ByteArrayOutputStream byteArrayOutputStream = null;
try {
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
try {
c cVar2 = new c(byteArrayOutputStream2, byteOrder);
R(cVar2);
byte[] byteArray = ((ByteArrayOutputStream) cVar2.f14329i).toByteArray();
cVar.write(byteArray);
CRC32 crc32 = new CRC32();
crc32.update(byteArray, 4, byteArray.length - 4);
cVar.e((int) crc32.getValue());
c(byteArrayOutputStream2);
f(dataInputStream, cVar);
} catch (Throwable th) {
th = th;
byteArrayOutputStream = byteArrayOutputStream2;
c(byteArrayOutputStream);
throw th;
}
} catch (Throwable th2) {
th = th2;
}
}
public final void K(InputStream inputStream, OutputStream outputStream) {
ByteArrayOutputStream byteArrayOutputStream;
int i2;
int i10;
int i11;
int readInt;
int i12;
int i13;
int i14;
if (f14296s) {
Objects.toString(inputStream);
Objects.toString(outputStream);
}
ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
b bVar = new b(inputStream, byteOrder);
c cVar = new c(outputStream, byteOrder);
byte[] bArr = H;
g(bVar, cVar, bArr.length);
byte[] bArr2 = I;
bVar.skipBytes(bArr2.length + 4);
try {
try {
byteArrayOutputStream = new ByteArrayOutputStream();
} catch (Throwable th) {
th = th;
byteArrayOutputStream = null;
}
} catch (Exception e10) {
e = e10;
}
try {
c cVar2 = new c(byteArrayOutputStream, byteOrder);
int i15 = this.f14317n;
if (i15 != 0) {
g(bVar, cVar2, ((i15 - ((bArr.length + 4) + bArr2.length)) - 4) - 4);
bVar.skipBytes(4);
bVar.skipBytes(bVar.readInt());
R(cVar2);
} else {
byte[] bArr3 = new byte[4];
if (bVar.read(bArr3) == 4) {
byte[] bArr4 = L;
boolean z10 = true;
if (Arrays.equals(bArr3, bArr4)) {
int readInt2 = bVar.readInt();
byte[] bArr5 = new byte[readInt2 % 2 == 1 ? readInt2 + 1 : readInt2];
bVar.read(bArr5);
bArr5[0] = (byte) (8 | bArr5[0]);
if (((bArr5[0] >> 1) & 1) != 1) {
z10 = false;
}
cVar2.write(bArr4);
cVar2.e(readInt2);
cVar2.write(bArr5);
if (z10) {
h(bVar, cVar2, O, null);
while (true) {
byte[] bArr6 = new byte[4];
inputStream.read(bArr6);
if (!Arrays.equals(bArr6, P)) {
break;
}
i(bVar, cVar2, bArr6);
}
R(cVar2);
} else {
h(bVar, cVar2, N, M);
R(cVar2);
}
} else {
byte[] bArr7 = N;
if (Arrays.equals(bArr3, bArr7) || Arrays.equals(bArr3, M)) {
int readInt3 = bVar.readInt();
int i16 = readInt3 % 2 == 1 ? readInt3 + 1 : readInt3;
byte[] bArr8 = new byte[3];
if (Arrays.equals(bArr3, bArr7)) {
bVar.read(bArr8);
byte[] bArr9 = new byte[3];
if (bVar.read(bArr9) == 3 && Arrays.equals(K, bArr9)) {
i2 = bVar.readInt();
i10 = (i2 << 18) >> 18;
i11 = (i2 << 2) >> 18;
i16 -= 10;
} else {
throw new IOException("Encountered error while checking VP8 signature");
}
} else if (!Arrays.equals(bArr3, M)) {
i2 = 0;
i10 = 0;
i11 = 0;
} else if (bVar.readByte() == 47) {
readInt = bVar.readInt();
i12 = ((readInt << 18) >> 18) + 1;
i13 = ((readInt << 4) >> 18) + 1;
i14 = readInt & 8;
i16 -= 5;
cVar2.write(bArr4);
cVar2.e(10);
byte[] bArr10 = new byte[10];
bArr10[0] = (byte) (bArr10[0] | 8);
bArr10[0] = (byte) (bArr10[0] | (i14 << 4));
int i17 = i12 - 1;
int i18 = i13 - 1;
bArr10[4] = (byte) i17;
bArr10[5] = (byte) (i17 >> 8);
bArr10[6] = (byte) (i17 >> 16);
bArr10[7] = (byte) i18;
bArr10[8] = (byte) (i18 >> 8);
bArr10[9] = (byte) (i18 >> 16);
cVar2.write(bArr10);
cVar2.write(bArr3);
cVar2.e(readInt3);
if (!Arrays.equals(bArr3, bArr7)) {
cVar2.write(bArr8);
cVar2.write(K);
cVar2.e(readInt);
} else if (Arrays.equals(bArr3, M)) {
cVar2.write(47);
cVar2.e(readInt);
}
g(bVar, cVar2, i16);
R(cVar2);
} else {
throw new IOException("Encountered error while checking VP8L signature");
}
i13 = i11;
i12 = i10;
readInt = i2;
i14 = 0;
cVar2.write(bArr4);
cVar2.e(10);
byte[] bArr102 = new byte[10];
bArr102[0] = (byte) (bArr102[0] | 8);
bArr102[0] = (byte) (bArr102[0] | (i14 << 4));
int i172 = i12 - 1;
int i182 = i13 - 1;
bArr102[4] = (byte) i172;
bArr102[5] = (byte) (i172 >> 8);
bArr102[6] = (byte) (i172 >> 16);
bArr102[7] = (byte) i182;
bArr102[8] = (byte) (i182 >> 8);
bArr102[9] = (byte) (i182 >> 16);
cVar2.write(bArr102);
cVar2.write(bArr3);
cVar2.e(readInt3);
if (!Arrays.equals(bArr3, bArr7)) {
}
g(bVar, cVar2, i16);
R(cVar2);
}
}
} else {
throw new IOException("Encountered invalid length while parsing WebP chunk type");
}
}
f(bVar, cVar2);
int size = byteArrayOutputStream.size();
byte[] bArr11 = I;
cVar.e(size + bArr11.length);
cVar.write(bArr11);
byteArrayOutputStream.writeTo(cVar);
c(byteArrayOutputStream);
} catch (Exception e11) {
e = e11;
throw new IOException("Failed to save WebP file", e);
} catch (Throwable th2) {
th = th2;
c(byteArrayOutputStream);
throw th;
}
}
public final void L(String str, String str2) {
e eVar;
int i2;
int i10;
d dVar;
Matcher matcher;
String str3 = str2;
String str4 = "ISOSpeedRatings".equals(str) ? "PhotographicSensitivity" : str;
int i11 = 2;
int i12 = 1;
if (str3 != null && f14290b0.contains(str4)) {
if (str4.equals("GPSTimeStamp")) {
if (!f14295g0.matcher(str3).find()) {
return;
}
str3 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1";
} else {
try {
str3 = new g(Double.parseDouble(str2)).toString();
} catch (NumberFormatException unused) {
return;
}
}
}
char c10 = 0;
int i13 = 0;
while (i13 < V.length) {
if ((i13 != 4 || this.f14311h) && (eVar = f14289a0[i13].get(str4)) != null) {
if (str3 == null) {
this.f14308e[i13].remove(str4);
} else {
Pair<Integer, Integer> w4 = w(str3);
if (eVar.f14337c != ((Integer) w4.first).intValue() && eVar.f14337c != ((Integer) w4.second).intValue()) {
int i14 = eVar.f14338d;
if (i14 != -1 && (i14 == ((Integer) w4.first).intValue() || eVar.f14338d == ((Integer) w4.second).intValue())) {
i2 = eVar.f14338d;
} else {
int i15 = eVar.f14337c;
if (i15 == i12 || i15 == 7 || i15 == i11) {
i2 = i15;
} else if (f14296s) {
String[] strArr = R;
String str5 = strArr[i15];
int i16 = eVar.f14338d;
if (i16 != -1) {
String str6 = strArr[i16];
}
String str7 = strArr[((Integer) w4.first).intValue()];
if (((Integer) w4.second).intValue() != -1) {
String str8 = strArr[((Integer) w4.second).intValue()];
}
}
}
} else {
i2 = eVar.f14337c;
}
switch (i2) {
case 1:
i10 = i13;
HashMap<String, d> hashMap = this.f14308e[i10];
if (str3.length() == 1 && str3.charAt(0) >= '0' && str3.charAt(0) <= '1') {
dVar = new d(1, 1, new byte[]{(byte) (str3.charAt(0) - '0')});
hashMap.put(str4, dVar);
continue;
i13 = i10 + 1;
i11 = 2;
i12 = 1;
c10 = 0;
}
byte[] bytes = str3.getBytes(f14292d0);
dVar = new d(1, bytes.length, bytes);
hashMap.put(str4, dVar);
continue;
i13 = i10 + 1;
i11 = 2;
i12 = 1;
c10 = 0;
break;
case 2:
case 7:
i10 = i13;
this.f14308e[i10].put(str4, d.a(str3));
break;
case 3:
i10 = i13;
String[] split = str3.split(",", -1);
int[] iArr = new int[split.length];
for (int i17 = 0; i17 < split.length; i17++) {
iArr[i17] = Integer.parseInt(split[i17]);
}
this.f14308e[i10].put(str4, d.f(iArr, this.f14310g));
break;
case 4:
i10 = i13;
String[] split2 = str3.split(",", -1);
long[] jArr = new long[split2.length];
for (int i18 = 0; i18 < split2.length; i18++) {
jArr[i18] = Long.parseLong(split2[i18]);
}
this.f14308e[i10].put(str4, d.c(jArr, this.f14310g));
break;
case 5:
i10 = i13;
String[] split3 = str3.split(",", -1);
g[] gVarArr = new g[split3.length];
for (int i19 = 0; i19 < split3.length; i19++) {
String[] split4 = split3[i19].split("/", -1);
gVarArr[i19] = new g((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1]));
}
this.f14308e[i10].put(str4, d.d(gVarArr, this.f14310g));
break;
case 9:
i10 = i13;
String[] split5 = str3.split(",", -1);
int length = split5.length;
int[] iArr2 = new int[length];
for (int i20 = 0; i20 < split5.length; i20++) {
iArr2[i20] = Integer.parseInt(split5[i20]);
}
HashMap<String, d> hashMap2 = this.f14308e[i10];
ByteOrder byteOrder = this.f14310g;
ByteBuffer wrap = ByteBuffer.wrap(new byte[S[9] * length]);
wrap.order(byteOrder);
for (int i21 = 0; i21 < length; i21++) {
wrap.putInt(iArr2[i21]);
}
hashMap2.put(str4, new d(9, length, wrap.array()));
break;
case 10:
String[] split6 = str3.split(",", -1);
int length2 = split6.length;
g[] gVarArr2 = new g[length2];
int i22 = 0;
while (i22 < split6.length) {
String[] split7 = split6[i22].split("/", -1);
gVarArr2[i22] = new g((long) Double.parseDouble(split7[c10]), (long) Double.parseDouble(split7[i12]));
i22++;
i13 = i13;
i12 = 1;
c10 = 0;
}
i10 = i13;
HashMap<String, d> hashMap3 = this.f14308e[i10];
ByteOrder byteOrder2 = this.f14310g;
ByteBuffer wrap2 = ByteBuffer.wrap(new byte[S[10] * length2]);
wrap2.order(byteOrder2);
for (int i23 = 0; i23 < length2; i23++) {
g gVar = gVarArr2[i23];
wrap2.putInt((int) gVar.f14339a);
wrap2.putInt((int) gVar.f14340b);
}
hashMap3.put(str4, new d(10, length2, wrap2.array()));
break;
case 12:
String[] split8 = str3.split(",", -1);
int length3 = split8.length;
double[] dArr = new double[length3];
for (int i24 = 0; i24 < split8.length; i24++) {
dArr[i24] = Double.parseDouble(split8[i24]);
}
HashMap<String, d> hashMap4 = this.f14308e[i13];
ByteOrder byteOrder3 = this.f14310g;
ByteBuffer wrap3 = ByteBuffer.wrap(new byte[S[12] * length3]);
wrap3.order(byteOrder3);
for (int i25 = 0; i25 < length3; i25++) {
wrap3.putDouble(dArr[i25]);
}
hashMap4.put(str4, new d(12, length3, wrap3.array()));
break;
}
i13 = i10 + 1;
i11 = 2;
i12 = 1;
c10 = 0;
}
}
i10 = i13;
i13 = i10 + 1;
i11 = 2;
i12 = 1;
c10 = 0;
}
}
public final void M(b bVar) {
boolean z10;
d dVar;
int h10;
HashMap<String, d> hashMap = this.f14308e[4];
d dVar2 = hashMap.get("Compression");
if (dVar2 != null) {
int h11 = dVar2.h(this.f14310g);
this.f14316m = h11;
if (h11 != 1) {
if (h11 == 6) {
x(bVar, hashMap);
return;
} else if (h11 != 7) {
return;
}
}
d dVar3 = hashMap.get("BitsPerSample");
if (dVar3 != null) {
int[] iArr = (int[]) dVar3.j(this.f14310g);
int[] iArr2 = f14299v;
if (Arrays.equals(iArr2, iArr) || (this.f14307d == 3 && (dVar = hashMap.get("PhotometricInterpretation")) != null && (((h10 = dVar.h(this.f14310g)) == 1 && Arrays.equals(iArr, f14300w)) || (h10 == 6 && Arrays.equals(iArr, iArr2))))) {
z10 = true;
if (z10) {
return;
}
d dVar4 = hashMap.get("StripOffsets");
d dVar5 = hashMap.get("StripByteCounts");
if (dVar4 == null || dVar5 == null) {
return;
}
long[] e10 = e(dVar4.j(this.f14310g));
long[] e11 = e(dVar5.j(this.f14310g));
if (e10 == null || e10.length == 0 || e11 == null || e11.length == 0 || e10.length != e11.length) {
return;
}
long j10 = 0;
for (long j11 : e11) {
j10 += j11;
}
int i2 = (int) j10;
byte[] bArr = new byte[i2];
this.f14312i = true;
this.f14311h = true;
int i10 = 0;
int i11 = 0;
for (int i12 = 0; i12 < e10.length; i12++) {
int i13 = (int) e10[i12];
int i14 = (int) e11[i12];
if (i12 < e10.length - 1 && i13 + i14 != e10[i12 + 1]) {
this.f14312i = false;
}
int i15 = i13 - i10;
if (i15 < 0) {
return;
}
long j12 = i15;
if (bVar.skip(j12) != j12) {
return;
}
int i16 = i10 + i15;
byte[] bArr2 = new byte[i14];
if (bVar.read(bArr2) != i14) {
return;
}
i10 = i16 + i14;
System.arraycopy(bArr2, 0, bArr, i11, i14);
i11 += i14;
}
this.f14315l = bArr;
if (this.f14312i) {
this.f14313j = (int) e10[0];
this.f14314k = i2;
return;
}
return;
}
}
z10 = false;
if (z10) {
}
} else {
this.f14316m = 6;
x(bVar, hashMap);
}
}
public final void O(int i2, int i10) {
if (this.f14308e[i2].isEmpty() || this.f14308e[i10].isEmpty()) {
return;
}
d dVar = this.f14308e[i2].get("ImageLength");
d dVar2 = this.f14308e[i2].get("ImageWidth");
d dVar3 = this.f14308e[i10].get("ImageLength");
d dVar4 = this.f14308e[i10].get("ImageWidth");
if (dVar == null || dVar2 == null || dVar3 == null || dVar4 == null) {
return;
}
int h10 = dVar.h(this.f14310g);
int h11 = dVar2.h(this.f14310g);
int h12 = dVar3.h(this.f14310g);
int h13 = dVar4.h(this.f14310g);
if (h10 >= h12 || h11 >= h13) {
return;
}
HashMap<String, d>[] hashMapArr = this.f14308e;
HashMap<String, d> hashMap = hashMapArr[i2];
hashMapArr[i2] = hashMapArr[i10];
hashMapArr[i10] = hashMap;
}
public final void P(b bVar, int i2) {
d e10;
d e11;
d dVar = this.f14308e[i2].get("DefaultCropSize");
d dVar2 = this.f14308e[i2].get("SensorTopBorder");
d dVar3 = this.f14308e[i2].get("SensorLeftBorder");
d dVar4 = this.f14308e[i2].get("SensorBottomBorder");
d dVar5 = this.f14308e[i2].get("SensorRightBorder");
if (dVar != null) {
if (dVar.f14331a == 5) {
g[] gVarArr = (g[]) dVar.j(this.f14310g);
if (gVarArr != null && gVarArr.length == 2) {
e10 = d.d(new g[]{gVarArr[0]}, this.f14310g);
e11 = d.d(new g[]{gVarArr[1]}, this.f14310g);
} else {
Arrays.toString(gVarArr);
return;
}
} else {
int[] iArr = (int[]) dVar.j(this.f14310g);
if (iArr != null && iArr.length == 2) {
e10 = d.e(iArr[0], this.f14310g);
e11 = d.e(iArr[1], this.f14310g);
} else {
Arrays.toString(iArr);
return;
}
}
this.f14308e[i2].put("ImageWidth", e10);
this.f14308e[i2].put("ImageLength", e11);
} else if (dVar2 != null && dVar3 != null && dVar4 != null && dVar5 != null) {
int h10 = dVar2.h(this.f14310g);
int h11 = dVar4.h(this.f14310g);
int h12 = dVar5.h(this.f14310g);
int h13 = dVar3.h(this.f14310g);
if (h11 <= h10 || h12 <= h13) {
return;
}
d e12 = d.e(h11 - h10, this.f14310g);
d e13 = d.e(h12 - h13, this.f14310g);
this.f14308e[i2].put("ImageLength", e12);
this.f14308e[i2].put("ImageWidth", e13);
} else {
d dVar6 = this.f14308e[i2].get("ImageLength");
d dVar7 = this.f14308e[i2].get("ImageWidth");
if (dVar6 == null || dVar7 == null) {
d dVar8 = this.f14308e[i2].get("JPEGInterchangeFormat");
d dVar9 = this.f14308e[i2].get("JPEGInterchangeFormatLength");
if (dVar8 == null || dVar9 == null) {
return;
}
int h14 = dVar8.h(this.f14310g);
int h15 = dVar8.h(this.f14310g);
bVar.e(h14);
byte[] bArr = new byte[h15];
bVar.read(bArr);
n(new b(bArr), h14, i2);
}
}
}
public final void Q() {
O(0, 5);
O(0, 4);
O(5, 4);
d dVar = this.f14308e[1].get("PixelXDimension");
d dVar2 = this.f14308e[1].get("PixelYDimension");
if (dVar != null && dVar2 != null) {
this.f14308e[0].put("ImageWidth", dVar);
this.f14308e[0].put("ImageLength", dVar2);
}
if (this.f14308e[4].isEmpty() && z(this.f14308e[5])) {
HashMap<String, d>[] hashMapArr = this.f14308e;
hashMapArr[4] = hashMapArr[5];
hashMapArr[5] = new HashMap<>();
}
z(this.f14308e[4]);
}
public final int R(c cVar) {
e[][] eVarArr = V;
int[] iArr = new int[eVarArr.length];
int[] iArr2 = new int[eVarArr.length];
for (e eVar : W) {
G(eVar.f14336b);
}
G(X.f14336b);
G(Y.f14336b);
for (int i2 = 0; i2 < V.length; i2++) {
for (Object obj : this.f14308e[i2].entrySet().toArray()) {
Map.Entry entry = (Map.Entry) obj;
if (entry.getValue() == null) {
this.f14308e[i2].remove(entry.getKey());
}
}
}
if (!this.f14308e[1].isEmpty()) {
this.f14308e[0].put(W[1].f14336b, d.b(0L, this.f14310g));
}
if (!this.f14308e[2].isEmpty()) {
this.f14308e[0].put(W[2].f14336b, d.b(0L, this.f14310g));
}
if (!this.f14308e[3].isEmpty()) {
this.f14308e[1].put(W[3].f14336b, d.b(0L, this.f14310g));
}
if (this.f14311h) {
this.f14308e[4].put(X.f14336b, d.b(0L, this.f14310g));
this.f14308e[4].put(Y.f14336b, d.b(this.f14314k, this.f14310g));
}
for (int i10 = 0; i10 < V.length; i10++) {
int i11 = 0;
for (Map.Entry<String, d> entry2 : this.f14308e[i10].entrySet()) {
d value = entry2.getValue();
Objects.requireNonNull(value);
int i12 = S[value.f14331a] * value.f14332b;
if (i12 > 4) {
i11 += i12;
}
}
iArr2[i10] = iArr2[i10] + i11;
}
int i13 = 8;
for (int i14 = 0; i14 < V.length; i14++) {
if (!this.f14308e[i14].isEmpty()) {
iArr[i14] = i13;
i13 = (this.f14308e[i14].size() * 12) + 2 + 4 + iArr2[i14] + i13;
}
}
if (this.f14311h) {
this.f14308e[4].put(X.f14336b, d.b(i13, this.f14310g));
this.f14313j = i13;
i13 += this.f14314k;
}
if (this.f14307d == 4) {
i13 += 8;
}
if (f14296s) {
for (int i15 = 0; i15 < V.length; i15++) {
String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d", Integer.valueOf(i15), Integer.valueOf(iArr[i15]), Integer.valueOf(this.f14308e[i15].size()), Integer.valueOf(iArr2[i15]), Integer.valueOf(i13));
}
}
if (!this.f14308e[1].isEmpty()) {
this.f14308e[0].put(W[1].f14336b, d.b(iArr[1], this.f14310g));
}
if (!this.f14308e[2].isEmpty()) {
this.f14308e[0].put(W[2].f14336b, d.b(iArr[2], this.f14310g));
}
if (!this.f14308e[3].isEmpty()) {
this.f14308e[1].put(W[3].f14336b, d.b(iArr[3], this.f14310g));
}
int i16 = this.f14307d;
if (i16 == 4) {
cVar.f((short) i13);
cVar.write(f14293e0);
} else if (i16 == 13) {
cVar.e(i13);
cVar.write(E);
} else if (i16 == 14) {
cVar.write(J);
cVar.e(i13);
}
cVar.f(this.f14310g == ByteOrder.BIG_ENDIAN ? (short) 19789 : (short) 18761);
cVar.f14330j = this.f14310g;
cVar.f((short) 42);
cVar.e((int) 8);
for (int i17 = 0; i17 < V.length; i17++) {
if (!this.f14308e[i17].isEmpty()) {
cVar.f((short) this.f14308e[i17].size());
int size = (this.f14308e[i17].size() * 12) + iArr[i17] + 2 + 4;
for (Map.Entry<String, d> entry3 : this.f14308e[i17].entrySet()) {
int i18 = f14289a0[i17].get(entry3.getKey()).f14335a;
d value2 = entry3.getValue();
Objects.requireNonNull(value2);
int i19 = S[value2.f14331a] * value2.f14332b;
cVar.f((short) i18);
cVar.f((short) value2.f14331a);
cVar.e(value2.f14332b);
if (i19 > 4) {
cVar.e(size);
size += i19;
} else {
cVar.write(value2.f14334d);
if (i19 < 4) {
while (i19 < 4) {
cVar.a(0);
i19++;
}
}
}
}
if (i17 == 0 && !this.f14308e[4].isEmpty()) {
cVar.e(iArr[4]);
} else {
cVar.e((int) 0);
}
for (Map.Entry<String, d> entry4 : this.f14308e[i17].entrySet()) {
byte[] bArr = entry4.getValue().f14334d;
if (bArr.length > 4) {
cVar.write(bArr, 0, bArr.length);
}
}
}
}
if (this.f14311h) {
cVar.write(u());
}
if (this.f14307d == 14 && i13 % 2 == 1) {
cVar.a(0);
}
cVar.f14330j = ByteOrder.BIG_ENDIAN;
return i13;
}
public final void a() {
String j10 = j("DateTimeOriginal");
if (j10 != null && j("DateTime") == null) {
this.f14308e[0].put("DateTime", d.a(j10));
}
if (j("ImageWidth") == null) {
this.f14308e[0].put("ImageWidth", d.b(0L, this.f14310g));
}
if (j("ImageLength") == null) {
this.f14308e[0].put("ImageLength", d.b(0L, this.f14310g));
}
if (j("Orientation") == null) {
this.f14308e[0].put("Orientation", d.b(0L, this.f14310g));
}
if (j("LightSource") == null) {
this.f14308e[1].put("LightSource", d.b(0L, this.f14310g));
}
}
public final void h(b bVar, c cVar, byte[] bArr, byte[] bArr2) {
String sb2;
while (true) {
byte[] bArr3 = new byte[4];
if (bVar.read(bArr3) != 4) {
StringBuilder r = j.r("Encountered invalid length while copying WebP chunks up tochunk type ");
Charset charset = f14292d0;
r.append(new String(bArr, charset));
if (bArr2 == null) {
sb2 = "";
} else {
StringBuilder r10 = j.r(" or ");
r10.append(new String(bArr2, charset));
sb2 = r10.toString();
}
r.append(sb2);
throw new IOException(r.toString());
}
i(bVar, cVar, bArr3);
if (Arrays.equals(bArr3, bArr)) {
return;
}
if (bArr2 != null && Arrays.equals(bArr3, bArr2)) {
return;
}
}
}
public final void i(b bVar, c cVar, byte[] bArr) {
int readInt = bVar.readInt();
cVar.write(bArr);
cVar.e(readInt);
if (readInt % 2 == 1) {
readInt++;
}
g(bVar, cVar, readInt);
}
public final String j(String str) {
Objects.requireNonNull(str, "tag shouldn't be null");
d l10 = l(str);
if (l10 != null) {
if (!f14290b0.contains(str)) {
return l10.i(this.f14310g);
}
if (str.equals("GPSTimeStamp")) {
int i2 = l10.f14331a;
if (i2 == 5 || i2 == 10) {
g[] gVarArr = (g[]) l10.j(this.f14310g);
if (gVarArr != null && gVarArr.length == 3) {
return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) gVarArr[0].f14339a) / ((float) gVarArr[0].f14340b))), Integer.valueOf((int) (((float) gVarArr[1].f14339a) / ((float) gVarArr[1].f14340b))), Integer.valueOf((int) (((float) gVarArr[2].f14339a) / ((float) gVarArr[2].f14340b))));
}
Arrays.toString(gVarArr);
return null;
}
return null;
}
try {
return Double.toString(l10.g(this.f14310g));
} catch (NumberFormatException unused) {
}
}
return null;
}
public final int k(String str, int i2) {
d l10 = l(str);
if (l10 == null) {
return i2;
}
try {
return l10.h(this.f14310g);
} catch (NumberFormatException unused) {
return i2;
}
}
public final d l(String str) {
Objects.requireNonNull(str, "tag shouldn't be null");
if ("ISOSpeedRatings".equals(str)) {
str = "PhotographicSensitivity";
}
for (int i2 = 0; i2 < V.length; i2++) {
d dVar = this.f14308e[i2].get(str);
if (dVar != null) {
return dVar;
}
}
return null;
}
public final void m(b bVar) {
String str;
String str2;
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
try {
if (Build.VERSION.SDK_INT >= 23) {
mediaMetadataRetriever.setDataSource(new C0256a(bVar));
} else {
FileDescriptor fileDescriptor = this.f14305b;
if (fileDescriptor != null) {
mediaMetadataRetriever.setDataSource(fileDescriptor);
} else {
String str3 = this.f14304a;
if (str3 == null) {
return;
}
mediaMetadataRetriever.setDataSource(str3);
}
}
String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
String str4 = null;
if ("yes".equals(extractMetadata3)) {
str4 = mediaMetadataRetriever.extractMetadata(29);
str = mediaMetadataRetriever.extractMetadata(30);
str2 = mediaMetadataRetriever.extractMetadata(31);
} else if ("yes".equals(extractMetadata4)) {
str4 = mediaMetadataRetriever.extractMetadata(18);
str = mediaMetadataRetriever.extractMetadata(19);
str2 = mediaMetadataRetriever.extractMetadata(24);
} else {
str = null;
str2 = null;
}
if (str4 != null) {
this.f14308e[0].put("ImageWidth", d.e(Integer.parseInt(str4), this.f14310g));
}
if (str != null) {
this.f14308e[0].put("ImageLength", d.e(Integer.parseInt(str), this.f14310g));
}
if (str2 != null) {
int i2 = 1;
int parseInt = Integer.parseInt(str2);
if (parseInt == 90) {
i2 = 6;
} else if (parseInt == 180) {
i2 = 3;
} else if (parseInt == 270) {
i2 = 8;
}
this.f14308e[0].put("Orientation", d.e(i2, this.f14310g));
}
if (extractMetadata != null && extractMetadata2 != null) {
int parseInt2 = Integer.parseInt(extractMetadata);
int parseInt3 = Integer.parseInt(extractMetadata2);
if (parseInt3 > 6) {
bVar.e(parseInt2);
byte[] bArr = new byte[6];
if (bVar.read(bArr) == 6) {
int i10 = parseInt2 + 6;
int i11 = parseInt3 - 6;
if (Arrays.equals(bArr, f14293e0)) {
byte[] bArr2 = new byte[i11];
if (bVar.read(bArr2) == i11) {
this.f14317n = i10;
E(bArr2, 0);
} else {
throw new IOException("Can't read exif");
}
} else {
throw new IOException("Invalid identifier");
}
} else {
throw new IOException("Can't read identifier");
}
} else {
throw new IOException("Invalid exif length");
}
}
} finally {
mediaMetadataRetriever.release();
}
}
public final void n(b bVar, int i2, int i10) {
if (f14296s) {
Objects.toString(bVar);
}
char c10 = 0;
bVar.mark(0);
bVar.f14326j = ByteOrder.BIG_ENDIAN;
byte readByte = bVar.readByte();
byte b10 = -1;
if (readByte == -1) {
if (bVar.readByte() != -40) {
StringBuilder r = j.r("Invalid marker: ");
r.append(Integer.toHexString(readByte & 255));
throw new IOException(r.toString());
}
int i11 = 2;
int i12 = 2;
while (true) {
byte readByte2 = bVar.readByte();
if (readByte2 == b10) {
int i13 = i12 + 1;
byte readByte3 = bVar.readByte();
boolean z10 = f14296s;
if (z10) {
Integer.toHexString(readByte3 & 255);
}
int i14 = i13 + 1;
if (readByte3 != -39 && readByte3 != -38) {
int readUnsignedShort = bVar.readUnsignedShort() - i11;
int i15 = i14 + i11;
if (z10) {
Integer.toHexString(readByte3 & 255);
}
if (readUnsignedShort < 0) {
throw new IOException("Invalid length");
}
if (readByte3 == -31) {
byte[] bArr = new byte[readUnsignedShort];
bVar.readFully(bArr);
int i16 = i15 + readUnsignedShort;
byte[] bArr2 = f14293e0;
if (N(bArr, bArr2)) {
byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
this.f14317n = i2 + i15 + bArr2.length;
E(copyOfRange, i10);
M(new b(copyOfRange));
} else {
byte[] bArr3 = f14294f0;
if (N(bArr, bArr3)) {
int length = i15 + bArr3.length;
byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
if (j("Xmp") == null) {
this.f14308e[c10].put("Xmp", new d(1, copyOfRange2.length, length, copyOfRange2));
this.r = true;
}
}
}
i15 = i16;
} else if (readByte3 != -2) {
switch (readByte3) {
default:
switch (readByte3) {
default:
switch (readByte3) {
default:
switch (readByte3) {
}
case -55:
case -54:
case -53:
if (bVar.skipBytes(1) == 1) {
this.f14308e[i10].put("ImageLength", d.b(bVar.readUnsignedShort(), this.f14310g));
this.f14308e[i10].put("ImageWidth", d.b(bVar.readUnsignedShort(), this.f14310g));
readUnsignedShort -= 5;
break;
} else {
throw new IOException("Invalid SOFx");
}
}
case -59:
case -58:
case -57:
break;
}
case -64:
case -63:
case -62:
case -61:
break;
}
if (readUnsignedShort < 0) {
if (bVar.skipBytes(readUnsignedShort) != readUnsignedShort) {
throw new IOException("Invalid JPEG segment");
}
i12 = i15 + readUnsignedShort;
c10 = 0;
i11 = 2;
b10 = -1;
} else {
throw new IOException("Invalid length");
}
} else {
byte[] bArr4 = new byte[readUnsignedShort];
if (bVar.read(bArr4) == readUnsignedShort) {
if (j("UserComment") == null) {
this.f14308e[1].put("UserComment", d.a(new String(bArr4, f14292d0)));
}
} else {
throw new IOException("Invalid exif");
}
}
readUnsignedShort = 0;
if (readUnsignedShort < 0) {
}
}
} else {
StringBuilder r10 = j.r("Invalid marker:");
r10.append(Integer.toHexString(readByte2 & 255));
throw new IOException(r10.toString());
}
}
} else {
StringBuilder r11 = j.r("Invalid marker: ");
r11.append(Integer.toHexString(readByte & 255));
throw new IOException(r11.toString());
}
}
public final int o(BufferedInputStream bufferedInputStream) {
boolean z10;
boolean z11;
boolean z12;
b bVar;
boolean z13;
a aVar;
b bVar2;
boolean z14;
boolean z15;
boolean z16;
b bVar3;
bufferedInputStream.mark(5000);
byte[] bArr = new byte[5000];
bufferedInputStream.read(bArr);
bufferedInputStream.reset();
int i2 = 0;
while (true) {
byte[] bArr2 = f14301x;
z10 = true;
if (i2 >= bArr2.length) {
z11 = true;
break;
} else if (bArr[i2] != bArr2[i2]) {
z11 = false;
break;
} else {
i2++;
}
}
if (z11) {
return 4;
}
byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
int i10 = 0;
while (true) {
if (i10 >= bytes.length) {
z12 = true;
break;
} else if (bArr[i10] != bytes[i10]) {
z12 = false;
break;
} else {
i10++;
}
}
if (z12) {
return 9;
}
b bVar4 = null;
try {
bVar = new b(bArr);
try {
long readInt = bVar.readInt();
byte[] bArr3 = new byte[4];
bVar.read(bArr3);
if (Arrays.equals(bArr3, f14302y)) {
long j10 = 16;
if (readInt == 1) {
readInt = bVar.readLong();
if (readInt < 16) {
}
} else {
j10 = 8;
}
long j11 = 5000;
if (readInt > j11) {
readInt = j11;
}
long j12 = readInt - j10;
if (j12 >= 8) {
byte[] bArr4 = new byte[4];
boolean z17 = false;
boolean z18 = false;
for (long j13 = 0; j13 < j12 / 4 && bVar.read(bArr4) == 4; j13++) {
if (j13 != 1) {
if (Arrays.equals(bArr4, f14303z)) {
z17 = true;
} else if (Arrays.equals(bArr4, A)) {
z18 = true;
}
if (z17 && z18) {
bVar.close();
z13 = true;
break;
}
}
}
}
}
} catch (Exception unused) {
} catch (Throwable th) {
th = th;
bVar4 = bVar;
if (bVar4 != null) {
bVar4.close();
}
throw th;
}
} catch (Exception unused2) {
bVar = null;
} catch (Throwable th2) {
th = th2;
}
bVar.close();
z13 = false;
if (z13) {
return 12;
}
try {
bVar2 = new b(bArr);
aVar = this;
try {
ByteOrder D2 = aVar.D(bVar2);
aVar.f14310g = D2;
bVar2.f14326j = D2;
short readShort = bVar2.readShort();
z14 = readShort == 20306 || readShort == 21330;
bVar2.close();
} catch (Exception unused3) {
if (bVar2 != null) {
bVar2.close();
}
z14 = false;
if (z14) {
}
} catch (Throwable th3) {
th = th3;
bVar4 = bVar2;
if (bVar4 != null) {
bVar4.close();
}
throw th;
}
} catch (Exception unused4) {
aVar = this;
bVar2 = null;
} catch (Throwable th4) {
th = th4;
}
if (z14) {
try {
bVar3 = new b(bArr);
} catch (Exception unused5) {
} catch (Throwable th5) {
th = th5;
}
try {
ByteOrder D3 = aVar.D(bVar3);
aVar.f14310g = D3;
bVar3.f14326j = D3;
z15 = bVar3.readShort() == 85;
bVar3.close();
} catch (Exception unused6) {
bVar4 = bVar3;
if (bVar4 != null) {
bVar4.close();
}
z15 = false;
if (z15) {
}
} catch (Throwable th6) {
th = th6;
bVar4 = bVar3;
if (bVar4 != null) {
bVar4.close();
}
throw th;
}
if (z15) {
int i11 = 0;
while (true) {
byte[] bArr5 = D;
if (i11 >= bArr5.length) {
z16 = true;
break;
} else if (bArr[i11] != bArr5[i11]) {
z16 = false;
break;
} else {
i11++;
}
}
if (z16) {
return 13;
}
int i12 = 0;
while (true) {
byte[] bArr6 = H;
if (i12 >= bArr6.length) {
int i13 = 0;
while (true) {
byte[] bArr7 = I;
if (i13 >= bArr7.length) {
break;
} else if (bArr[H.length + i13 + 4] != bArr7[i13]) {
break;
} else {
i13++;
}
}
} else if (bArr[i12] != bArr6[i12]) {
break;
} else {
i12++;
}
}
return z10 ? 14 : 0;
}
return 10;
}
return 7;
}
public final void p(b bVar) {
s(bVar);
d dVar = this.f14308e[1].get("MakerNote");
if (dVar != null) {
b bVar2 = new b(dVar.f14334d);
bVar2.f14326j = this.f14310g;
byte[] bArr = B;
byte[] bArr2 = new byte[bArr.length];
bVar2.readFully(bArr2);
bVar2.e(0L);
byte[] bArr3 = C;
byte[] bArr4 = new byte[bArr3.length];
bVar2.readFully(bArr4);
if (Arrays.equals(bArr2, bArr)) {
bVar2.e(8L);
} else if (Arrays.equals(bArr4, bArr3)) {
bVar2.e(12L);
}
F(bVar2, 6);
d dVar2 = this.f14308e[7].get("PreviewImageStart");
d dVar3 = this.f14308e[7].get("PreviewImageLength");
if (dVar2 != null && dVar3 != null) {
this.f14308e[5].put("JPEGInterchangeFormat", dVar2);
this.f14308e[5].put("JPEGInterchangeFormatLength", dVar3);
}
d dVar4 = this.f14308e[8].get("AspectFrame");
if (dVar4 != null) {
int[] iArr = (int[]) dVar4.j(this.f14310g);
if (iArr != null && iArr.length == 4) {
if (iArr[2] <= iArr[0] || iArr[3] <= iArr[1]) {
return;
}
int i2 = (iArr[2] - iArr[0]) + 1;
int i10 = (iArr[3] - iArr[1]) + 1;
if (i2 < i10) {
int i11 = i2 + i10;
i10 = i11 - i10;
i2 = i11 - i10;
}
d e10 = d.e(i2, this.f14310g);
d e11 = d.e(i10, this.f14310g);
this.f14308e[0].put("ImageWidth", e10);
this.f14308e[0].put("ImageLength", e11);
return;
}
Arrays.toString(iArr);
}
}
}
public final void q(b bVar) {
if (f14296s) {
Objects.toString(bVar);
}
bVar.mark(0);
bVar.f14326j = ByteOrder.BIG_ENDIAN;
byte[] bArr = D;
bVar.skipBytes(bArr.length);
int length = bArr.length + 0;
while (true) {
try {
int readInt = bVar.readInt();
int i2 = length + 4;
byte[] bArr2 = new byte[4];
if (bVar.read(bArr2) == 4) {
int i10 = i2 + 4;
if (i10 == 16 && !Arrays.equals(bArr2, F)) {
throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
}
if (Arrays.equals(bArr2, G)) {
return;
}
if (Arrays.equals(bArr2, E)) {
byte[] bArr3 = new byte[readInt];
if (bVar.read(bArr3) == readInt) {
int readInt2 = bVar.readInt();
CRC32 crc32 = new CRC32();
crc32.update(bArr2);
crc32.update(bArr3);
if (((int) crc32.getValue()) == readInt2) {
this.f14317n = i10;
E(bArr3, 0);
Q();
M(new b(bArr3));
return;
}
throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
}
throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr2));
}
int i11 = readInt + 4;
bVar.skipBytes(i11);
length = i10 + i11;
} else {
throw new IOException("Encountered invalid length while parsing PNG chunktype");
}
} catch (EOFException unused) {
throw new IOException("Encountered corrupt PNG file.");
}
}
}
public final void r(b bVar) {
if (f14296s) {
Objects.toString(bVar);
}
bVar.mark(0);
bVar.skipBytes(84);
byte[] bArr = new byte[4];
byte[] bArr2 = new byte[4];
byte[] bArr3 = new byte[4];
bVar.read(bArr);
bVar.read(bArr2);
bVar.read(bArr3);
int i2 = ByteBuffer.wrap(bArr).getInt();
int i10 = ByteBuffer.wrap(bArr2).getInt();
int i11 = ByteBuffer.wrap(bArr3).getInt();
byte[] bArr4 = new byte[i10];
bVar.e(i2);
bVar.read(bArr4);
n(new b(bArr4), i2, 5);
bVar.e(i11);
bVar.f14326j = ByteOrder.BIG_ENDIAN;
int readInt = bVar.readInt();
for (int i12 = 0; i12 < readInt; i12++) {
int readUnsignedShort = bVar.readUnsignedShort();
int readUnsignedShort2 = bVar.readUnsignedShort();
if (readUnsignedShort == U.f14335a) {
short readShort = bVar.readShort();
short readShort2 = bVar.readShort();
d e10 = d.e(readShort, this.f14310g);
d e11 = d.e(readShort2, this.f14310g);
this.f14308e[0].put("ImageLength", e10);
this.f14308e[0].put("ImageWidth", e11);
return;
}
bVar.skipBytes(readUnsignedShort2);
}
}
public final void s(b bVar) {
d dVar;
B(bVar, bVar.available());
F(bVar, 0);
P(bVar, 0);
P(bVar, 5);
P(bVar, 4);
Q();
if (this.f14307d != 8 || (dVar = this.f14308e[1].get("MakerNote")) == null) {
return;
}
b bVar2 = new b(dVar.f14334d);
bVar2.f14326j = this.f14310g;
bVar2.e(6L);
F(bVar2, 9);
d dVar2 = this.f14308e[9].get("ColorSpace");
if (dVar2 != null) {
this.f14308e[1].put("ColorSpace", dVar2);
}
}
public final void t(b bVar) {
if (f14296s) {
Objects.toString(bVar);
}
s(bVar);
d dVar = this.f14308e[0].get("JpgFromRaw");
if (dVar != null) {
n(new b(dVar.f14334d), (int) dVar.f14333c, 5);
}
d dVar2 = this.f14308e[0].get("ISO");
d dVar3 = this.f14308e[1].get("PhotographicSensitivity");
if (dVar2 == null || dVar3 != null) {
return;
}
this.f14308e[1].put("PhotographicSensitivity", dVar2);
}
public final byte[] u() {
Throwable th;
FileDescriptor fileDescriptor;
InputStream inputStream;
FileDescriptor fileDescriptor2;
InputStream inputStream2 = null;
if (!this.f14311h) {
return null;
}
byte[] bArr = this.f14315l;
if (bArr != null) {
return bArr;
}
try {
inputStream = this.f14306c;
} catch (Exception unused) {
inputStream = null;
fileDescriptor2 = null;
} catch (Throwable th2) {
th = th2;
fileDescriptor = null;
}
try {
if (inputStream != null) {
try {
if (inputStream.markSupported()) {
inputStream.reset();
} else {
c(inputStream);
return null;
}
} catch (Exception unused2) {
fileDescriptor2 = null;
c(inputStream);
if (fileDescriptor2 != null) {
}
return null;
} catch (Throwable th3) {
th = th3;
inputStream2 = inputStream;
fileDescriptor = null;
c(inputStream2);
if (fileDescriptor != null) {
}
throw th;
}
} else if (this.f14304a != null) {
inputStream = new FileInputStream(this.f14304a);
} else {
FileDescriptor fileDescriptor3 = this.f14305b;
if (fileDescriptor3 != null) {
try {
fileDescriptor = Os.dup(fileDescriptor3);
try {
f.a(fileDescriptor, OsConstants.SEEK_SET);
fileDescriptor2 = fileDescriptor;
inputStream = new FileInputStream(fileDescriptor);
} catch (Exception unused3) {
fileDescriptor2 = fileDescriptor;
inputStream = null;
c(inputStream);
if (fileDescriptor2 != null) {
try {
Os.close(fileDescriptor2);
} catch (ErrnoException unused4) {
}
}
return null;
} catch (Throwable th4) {
th = th4;
c(inputStream2);
if (fileDescriptor != null) {
try {
Os.close(fileDescriptor);
} catch (ErrnoException unused5) {
}
}
throw th;
}
} catch (ErrnoException e10) {
throw new IOException("Failed to duplicate file descriptor", e10);
}
} else {
inputStream = null;
fileDescriptor2 = null;
}
if (inputStream == null) {
if (inputStream.skip(this.f14313j + this.f14317n) == this.f14313j + this.f14317n) {
byte[] bArr2 = new byte[this.f14314k];
if (inputStream.read(bArr2) == this.f14314k) {
this.f14315l = bArr2;
c(inputStream);
if (fileDescriptor2 != null) {
try {
Os.close(fileDescriptor2);
} catch (ErrnoException unused6) {
}
}
return bArr2;
}
throw new IOException("Corrupted image");
}
throw new IOException("Corrupted image");
}
throw new FileNotFoundException();
}
if (inputStream == null) {
}
} catch (Exception unused7) {
c(inputStream);
if (fileDescriptor2 != null) {
}
return null;
} catch (Throwable th5) {
inputStream2 = inputStream;
fileDescriptor = fileDescriptor2;
th = th5;
c(inputStream2);
if (fileDescriptor != null) {
}
throw th;
}
fileDescriptor2 = null;
}
public final void v(b bVar) {
if (f14296s) {
Objects.toString(bVar);
}
bVar.mark(0);
bVar.f14326j = ByteOrder.LITTLE_ENDIAN;
bVar.skipBytes(H.length);
int readInt = bVar.readInt() + 8;
int skipBytes = bVar.skipBytes(I.length) + 8;
while (true) {
try {
byte[] bArr = new byte[4];
if (bVar.read(bArr) == 4) {
int readInt2 = bVar.readInt();
int i2 = skipBytes + 4 + 4;
if (Arrays.equals(J, bArr)) {
byte[] bArr2 = new byte[readInt2];
if (bVar.read(bArr2) == readInt2) {
this.f14317n = i2;
E(bArr2, 0);
M(new b(bArr2));
return;
}
throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr));
}
if (readInt2 % 2 == 1) {
readInt2++;
}
int i10 = i2 + readInt2;
if (i10 == readInt) {
return;
}
if (i10 <= readInt) {
int skipBytes2 = bVar.skipBytes(readInt2);
if (skipBytes2 != readInt2) {
throw new IOException("Encountered WebP file with invalid chunk size");
}
skipBytes = i2 + skipBytes2;
} else {
throw new IOException("Encountered WebP file with invalid chunk size");
}
} else {
throw new IOException("Encountered invalid length while parsing WebP chunktype");
}
} catch (EOFException unused) {
throw new IOException("Encountered corrupt WebP file.");
}
}
}
public final void x(b bVar, HashMap hashMap) {
d dVar = (d) hashMap.get("JPEGInterchangeFormat");
d dVar2 = (d) hashMap.get("JPEGInterchangeFormatLength");
if (dVar == null || dVar2 == null) {
return;
}
int h10 = dVar.h(this.f14310g);
int h11 = dVar2.h(this.f14310g);
if (this.f14307d == 7) {
h10 += this.f14318o;
}
int min = Math.min(h11, bVar.f14327k - h10);
if (h10 <= 0 || min <= 0) {
return;
}
this.f14311h = true;
if (this.f14304a == null && this.f14306c == null && this.f14305b == null) {
byte[] bArr = new byte[min];
bVar.skip(h10);
bVar.read(bArr);
this.f14315l = bArr;
}
this.f14313j = h10;
this.f14314k = min;
}
public final boolean z(HashMap hashMap) {
d dVar = (d) hashMap.get("ImageLength");
d dVar2 = (d) hashMap.get("ImageWidth");
if (dVar == null || dVar2 == null) {
return false;
}
return dVar.h(this.f14310g) <= 512 && dVar2.h(this.f14310g) <= 512;
}
public static class b extends InputStream implements DataInput {
public static final ByteOrder f14323m = ByteOrder.LITTLE_ENDIAN;
public static final ByteOrder f14324n = ByteOrder.BIG_ENDIAN;
public DataInputStream f14325i;
public ByteOrder f14326j;
public final int f14327k;
public int f14328l;
public b(InputStream inputStream, ByteOrder byteOrder) {
this.f14326j = ByteOrder.BIG_ENDIAN;
DataInputStream dataInputStream = new DataInputStream(inputStream);
this.f14325i = dataInputStream;
int available = dataInputStream.available();
this.f14327k = available;
this.f14328l = 0;
this.f14325i.mark(available);
this.f14326j = byteOrder;
}
public final long a() {
return readInt() & 4294967295L;
}
@Override
public final int available() {
return this.f14325i.available();
}
public final void e(long j10) {
int i2 = this.f14328l;
if (i2 > j10) {
this.f14328l = 0;
this.f14325i.reset();
this.f14325i.mark(this.f14327k);
} else {
j10 -= i2;
}
int i10 = (int) j10;
if (skipBytes(i10) != i10) {
throw new IOException("Couldn't seek up to the byteCount");
}
}
@Override
public final synchronized void mark(int i2) {
this.f14325i.mark(i2);
}
@Override
public final int read() {
this.f14328l++;
return this.f14325i.read();
}
@Override
public final boolean readBoolean() {
this.f14328l++;
return this.f14325i.readBoolean();
}
@Override
public final byte readByte() {
int i2 = this.f14328l + 1;
this.f14328l = i2;
if (i2 <= this.f14327k) {
int read = this.f14325i.read();
if (read >= 0) {
return (byte) read;
}
throw new EOFException();
}
throw new EOFException();
}
@Override
public final char readChar() {
this.f14328l += 2;
return this.f14325i.readChar();
}
@Override
public final double readDouble() {
return Double.longBitsToDouble(readLong());
}
@Override
public final float readFloat() {
return Float.intBitsToFloat(readInt());
}
@Override
public final void readFully(byte[] bArr, int i2, int i10) {
int i11 = this.f14328l + i10;
this.f14328l = i11;
if (i11 <= this.f14327k) {
if (this.f14325i.read(bArr, i2, i10) != i10) {
throw new IOException("Couldn't read up to the length of buffer");
}
return;
}
throw new EOFException();
}
@Override
public final int readInt() {
int i2 = this.f14328l + 4;
this.f14328l = i2;
if (i2 <= this.f14327k) {
int read = this.f14325i.read();
int read2 = this.f14325i.read();
int read3 = this.f14325i.read();
int read4 = this.f14325i.read();
if ((read | read2 | read3 | read4) >= 0) {
ByteOrder byteOrder = this.f14326j;
if (byteOrder == f14323m) {
return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
}
if (byteOrder == f14324n) {
return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
}
StringBuilder r = j.r("Invalid byte order: ");
r.append(this.f14326j);
throw new IOException(r.toString());
}
throw new EOFException();
}
throw new EOFException();
}
@Override
public final String readLine() {
return null;
}
@Override
public final long readLong() {
int i2 = this.f14328l + 8;
this.f14328l = i2;
if (i2 <= this.f14327k) {
int read = this.f14325i.read();
int read2 = this.f14325i.read();
int read3 = this.f14325i.read();
int read4 = this.f14325i.read();
int read5 = this.f14325i.read();
int read6 = this.f14325i.read();
int read7 = this.f14325i.read();
int read8 = this.f14325i.read();
if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
ByteOrder byteOrder = this.f14326j;
if (byteOrder == f14323m) {
return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
}
if (byteOrder == f14324n) {
return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
}
StringBuilder r = j.r("Invalid byte order: ");
r.append(this.f14326j);
throw new IOException(r.toString());
}
throw new EOFException();
}
throw new EOFException();
}
@Override
public final short readShort() {
int i2 = this.f14328l + 2;
this.f14328l = i2;
if (i2 <= this.f14327k) {
int read = this.f14325i.read();
int read2 = this.f14325i.read();
if ((read | read2) >= 0) {
ByteOrder byteOrder = this.f14326j;
if (byteOrder == f14323m) {
return (short) ((read2 << 8) + read);
}
if (byteOrder == f14324n) {
return (short) ((read << 8) + read2);
}
StringBuilder r = j.r("Invalid byte order: ");
r.append(this.f14326j);
throw new IOException(r.toString());
}
throw new EOFException();
}
throw new EOFException();
}
@Override
public final String readUTF() {
this.f14328l += 2;
return this.f14325i.readUTF();
}
@Override
public final int readUnsignedByte() {
this.f14328l++;
return this.f14325i.readUnsignedByte();
}
@Override
public final int readUnsignedShort() {
int i2 = this.f14328l + 2;
this.f14328l = i2;
if (i2 <= this.f14327k) {
int read = this.f14325i.read();
int read2 = this.f14325i.read();
if ((read | read2) >= 0) {
ByteOrder byteOrder = this.f14326j;
if (byteOrder == f14323m) {
return (read2 << 8) + read;
}
if (byteOrder == f14324n) {
return (read << 8) + read2;
}
StringBuilder r = j.r("Invalid byte order: ");
r.append(this.f14326j);
throw new IOException(r.toString());
}
throw new EOFException();
}
throw new EOFException();
}
@Override
public final int skipBytes(int i2) {
int min = Math.min(i2, this.f14327k - this.f14328l);
int i10 = 0;
while (i10 < min) {
i10 += this.f14325i.skipBytes(min - i10);
}
this.f14328l += i10;
return i10;
}
@Override
public final int read(byte[] bArr, int i2, int i10) {
int read = this.f14325i.read(bArr, i2, i10);
this.f14328l += read;
return read;
}
@Override
public final void readFully(byte[] bArr) {
int length = this.f14328l + bArr.length;
this.f14328l = length;
if (length <= this.f14327k) {
if (this.f14325i.read(bArr, 0, bArr.length) != bArr.length) {
throw new IOException("Couldn't read up to the length of buffer");
}
return;
}
throw new EOFException();
}
public b(byte[] bArr) {
this(new ByteArrayInputStream(bArr), ByteOrder.BIG_ENDIAN);
}
}
public static class e {
public final int f14335a;
public final String f14336b;
public final int f14337c;
public final int f14338d;
public e(String str, int i2, int i10) {
this.f14336b = str;
this.f14335a = i2;
this.f14337c = i10;
this.f14338d = -1;
}
public e(String str, int i2) {
this.f14336b = str;
this.f14335a = i2;
this.f14337c = 3;
this.f14338d = 4;
}
}
public a(FileDescriptor fileDescriptor) {
FileInputStream fileInputStream;
e[][] eVarArr = V;
this.f14308e = new HashMap[eVarArr.length];
this.f14309f = new HashSet(eVarArr.length);
this.f14310g = ByteOrder.BIG_ENDIAN;
Objects.requireNonNull(fileDescriptor, "fileDescriptor cannot be null");
FileInputStream fileInputStream2 = null;
this.f14306c = null;
this.f14304a = null;
boolean z10 = false;
if (y(fileDescriptor)) {
this.f14305b = fileDescriptor;
try {
fileDescriptor = Os.dup(fileDescriptor);
z10 = true;
} catch (ErrnoException e10) {
throw new IOException("Failed to duplicate file descriptor", e10);
}
} else {
this.f14305b = null;
}
try {
fileInputStream = new FileInputStream(fileDescriptor);
} catch (Throwable th) {
th = th;
}
try {
A(fileInputStream);
c(fileInputStream);
if (z10) {
try {
Os.close(fileDescriptor);
} catch (ErrnoException unused) {
}
}
} catch (Throwable th2) {
th = th2;
fileInputStream2 = fileInputStream;
c(fileInputStream2);
if (z10) {
try {
Os.close(fileDescriptor);
} catch (ErrnoException unused2) {
}
}
throw th;
}
}
public a(InputStream inputStream) {
e[][] eVarArr = V;
this.f14308e = new HashMap[eVarArr.length];
this.f14309f = new HashSet(eVarArr.length);
this.f14310g = ByteOrder.BIG_ENDIAN;
Objects.requireNonNull(inputStream, "inputStream cannot be null");
this.f14304a = null;
if (inputStream instanceof AssetManager.AssetInputStream) {
this.f14306c = (AssetManager.AssetInputStream) inputStream;
this.f14305b = null;
} else {
if (inputStream instanceof FileInputStream) {
FileInputStream fileInputStream = (FileInputStream) inputStream;
if (y(fileInputStream.getFD())) {
this.f14306c = null;
this.f14305b = fileInputStream.getFD();
}
}
this.f14306c = null;
this.f14305b = null;
}
A(inputStream);
}
}