金三角 v1.1.9版本的 MD5 值为:8e4caacc812856d95de01918be356a47

以下内容为反编译后的 a.java 源代码,内容仅作参考


package c.n.a;

import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import com.luck.picture.lib.camera.CustomCameraView;
import com.shuyu.gsyvideoplayer.utils.NeuQuant;
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 okhttp3.internal.ws.WebSocketProtocol;
public class a {
    public static final e[] D;
    public static final e[] E;
    public static final e[] F;
    public static final e[] G;
    public static final e[] H;
    public static final e I;
    public static final e[] J;
    public static final e[] K;
    public static final e[] L;
    public static final e[] M;
    public static final e[][] N;
    public static final e[] O;
    public static final e P;
    public static final e Q;
    public static final HashMap<Integer, e>[] R;
    public static final HashMap<String, e>[] S;
    public static final HashSet<String> T;
    public static final HashMap<Integer, Integer> U;
    public static final Charset V;
    public static final byte[] W;
    public static final byte[] X;
    public static final Pattern Y;
    public static final Pattern Z;
    public static final Pattern a0;
    public static SimpleDateFormat y;
    public static SimpleDateFormat z;
    public String b0;
    public FileDescriptor c0;
    public AssetManager.AssetInputStream d0;
    public int e0;
    public boolean f0;
    public final HashMap<String, d>[] g0;
    public Set<Integer> h0;
    public ByteOrder i0;
    public boolean j0;
    public boolean k0;
    public int l0;
    public int m0;
    public byte[] n0;
    public int o0;
    public int p0;
    public int q0;
    public int r0;
    public int s0;
    public boolean t0;
    public static final boolean a = Log.isLoggable("ExifInterface", 3);
    public static final List<Integer> f2741b = Arrays.asList(1, 6, 3, 8);
    public static final List<Integer> f2742c = Arrays.asList(2, 7, 4, 5);
    public static final int[] f2743d = {8, 8, 8};
    public static final int[] f2744e = {8};
    public static final byte[] f2745f = {-1, -40, -1};
    public static final byte[] f2746g = {102, 116, 121, 112};
    public static final byte[] f2747h = {109, 105, 102, 49};
    public static final byte[] f2748i = {104, 101, 105, 99};
    public static final byte[] f2749j = {79, 76, 89, 77, 80, 0};
    public static final byte[] f2750k = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] f2751l = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] f2752m = {101, 88, 73, 102};
    public static final byte[] n = {73, 72, 68, 82};
    public static final byte[] o = {73, 69, 78, 68};
    public static final byte[] p = {82, 73, 70, 70};
    public static final byte[] q = {87, 69, 66, 80};
    public static final byte[] r = {69, 88, 73, 70};
    public static final byte[] s = {-99, 1, 42};
    public static final byte[] t = "VP8X".getBytes(Charset.defaultCharset());
    public static final byte[] u = "VP8L".getBytes(Charset.defaultCharset());
    public static final byte[] v = "VP8 ".getBytes(Charset.defaultCharset());
    public static final byte[] w = "ANIM".getBytes(Charset.defaultCharset());
    public static final byte[] x = "ANMF".getBytes(Charset.defaultCharset());
    public static final String[] A = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    public static final int[] B = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    public static final byte[] C = {65, 83, 67, 73, 73, 0, 0, 0};

    public class C0028a extends MediaDataSource {
        public long f2753d;
        public final b f2754h;

        public C0028a(a aVar, b bVar) {
            this.f2754h = bVar;
        }

        @Override
        public void close() {
        }

        @Override
        public long getSize() {
            return -1L;
        }

        @Override
        public int readAt(long j2, byte[] bArr, int i2, int i3) {
            if (i3 == 0) {
                return 0;
            }
            if (j2 < 0) {
                return -1;
            }
            try {
                long j3 = this.f2753d;
                if (j3 != j2) {
                    if (j3 >= 0 && j2 >= j3 + this.f2754h.available()) {
                        return -1;
                    }
                    this.f2754h.b(j2);
                    this.f2753d = j2;
                }
                if (i3 > this.f2754h.available()) {
                    i3 = this.f2754h.available();
                }
                b bVar = this.f2754h;
                int read = bVar.f2757m.read(bArr, i2, i3);
                bVar.p += read;
                if (read >= 0) {
                    this.f2753d += read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.f2753d = -1L;
            return -1;
        }
    }

    public static class c extends FilterOutputStream {
        public final OutputStream f2758d;
        public ByteOrder f2759h;

        public c(OutputStream outputStream, ByteOrder byteOrder) {
            super(outputStream);
            this.f2758d = outputStream;
            this.f2759h = byteOrder;
        }

        public void a(int i2) {
            ByteOrder byteOrder = this.f2759h;
            if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
                this.f2758d.write((i2 >>> 0) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 8) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 16) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 24) & NeuQuant.maxnetpos);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                this.f2758d.write((i2 >>> 24) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 16) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 8) & NeuQuant.maxnetpos);
                this.f2758d.write((i2 >>> 0) & NeuQuant.maxnetpos);
            }
        }

        public void b(short s) {
            ByteOrder byteOrder = this.f2759h;
            if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
                this.f2758d.write((s >>> 0) & NeuQuant.maxnetpos);
                this.f2758d.write((s >>> 8) & NeuQuant.maxnetpos);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                this.f2758d.write((s >>> 8) & NeuQuant.maxnetpos);
                this.f2758d.write((s >>> 0) & NeuQuant.maxnetpos);
            }
        }

        @Override
        public void write(byte[] bArr) {
            this.f2758d.write(bArr);
        }

        @Override
        public void write(byte[] bArr, int i2, int i3) {
            this.f2758d.write(bArr, i2, i3);
        }
    }

    public static class f {
        public final long a;
        public final long f2766b;

        public f(double d2) {
            this((long) (d2 * 10000.0d), 10000L);
        }

        public String toString() {
            return this.a + "/" + this.f2766b;
        }

        public f(long j2, long j3) {
            if (j3 == 0) {
                this.a = 0L;
                this.f2766b = 1L;
                return;
            }
            this.a = j2;
            this.f2766b = j3;
        }
    }

    static {
        e[] eVarArr;
        e[] eVarArr2 = {new e("NewSubfileType", 254, 4), new e("SubfileType", NeuQuant.maxnetpos, 4), new e("ImageWidth", 256, 3, 4), new e("ImageLength", CustomCameraView.BUTTON_STATE_ONLY_CAPTURE, 3, 4), 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", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273, 3, 4), new e("Orientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278, 3, 4), new e("StripByteCounts", 279, 3, 4), 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", TypedValues.Attributes.TYPE_PIVOT_TARGET, 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)};
        D = eVarArr2;
        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, 3, 4), new e("PixelYDimension", 40963, 3, 4), 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, 3, 4)};
        E = eVarArr3;
        e[] eVarArr4 = {new e("GPSVersionID", 0, 1), new e("GPSLatitudeRef", 1, 2), new e("GPSLatitude", 2, 5, 10), new e("GPSLongitudeRef", 3, 2), new e("GPSLongitude", 4, 5, 10), 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)};
        F = eVarArr4;
        e[] eVarArr5 = {new e("InteroperabilityIndex", 1, 2)};
        G = eVarArr5;
        e[] eVarArr6 = {new e("NewSubfileType", 254, 4), new e("SubfileType", NeuQuant.maxnetpos, 4), new e("ThumbnailImageWidth", 256, 3, 4), new e("ThumbnailImageLength", CustomCameraView.BUTTON_STATE_ONLY_CAPTURE, 3, 4), 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", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273, 3, 4), new e("ThumbnailOrientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278, 3, 4), new e("StripByteCounts", 279, 3, 4), 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", TypedValues.Attributes.TYPE_PIVOT_TARGET, 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, 3, 4)};
        H = eVarArr6;
        I = new e("StripOffsets", 273, 3);
        e[] eVarArr7 = {new e("ThumbnailImage", 256, 7), new e("CameraSettingsIFDPointer", 8224, 4), new e("ImageProcessingIFDPointer", 8256, 4)};
        J = eVarArr7;
        e[] eVarArr8 = {new e("PreviewImageStart", CustomCameraView.BUTTON_STATE_ONLY_CAPTURE, 4), new e("PreviewImageLength", CustomCameraView.BUTTON_STATE_ONLY_RECORDER, 4)};
        K = eVarArr8;
        e[] eVarArr9 = {new e("AspectFrame", 4371, 3)};
        L = eVarArr9;
        e[] eVarArr10 = {new e("ColorSpace", 55, 3)};
        M = eVarArr10;
        e[][] eVarArr11 = {eVarArr2, eVarArr3, eVarArr4, eVarArr5, eVarArr6, eVarArr2, eVarArr7, eVarArr8, eVarArr9, eVarArr10};
        N = eVarArr11;
        O = 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)};
        P = new e("JPEGInterchangeFormat", 513, 4);
        Q = new e("JPEGInterchangeFormatLength", 514, 4);
        R = new HashMap[eVarArr11.length];
        S = new HashMap[eVarArr11.length];
        T = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        U = new HashMap<>();
        Charset forName = Charset.forName("US-ASCII");
        V = forName;
        W = "Exif\u0000\u0000".getBytes(forName);
        X = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        Locale locale = Locale.US;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale);
        y = simpleDateFormat;
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale);
        z = simpleDateFormat2;
        simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
        int i2 = 0;
        while (true) {
            e[][] eVarArr12 = N;
            if (i2 < eVarArr12.length) {
                R[i2] = new HashMap<>();
                S[i2] = new HashMap<>();
                for (e eVar : eVarArr12[i2]) {
                    R[i2].put(Integer.valueOf(eVar.a), eVar);
                    S[i2].put(eVar.f2763b, eVar);
                }
                i2++;
            } else {
                HashMap<Integer, Integer> hashMap = U;
                e[] eVarArr13 = O;
                hashMap.put(Integer.valueOf(eVarArr13[0].a), 5);
                hashMap.put(Integer.valueOf(eVarArr13[1].a), 1);
                hashMap.put(Integer.valueOf(eVarArr13[2].a), 2);
                hashMap.put(Integer.valueOf(eVarArr13[3].a), 3);
                hashMap.put(Integer.valueOf(eVarArr13[4].a), 7);
                hashMap.put(Integer.valueOf(eVarArr13[5].a), 8);
                Pattern.compile(".*[1-9].*");
                Y = Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})$");
                Z = Pattern.compile("^(\\d{4}):(\\d{2}):(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                a0 = Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                return;
            }
        }
    }

    public a(String str) {
        FileInputStream fileInputStream;
        e[][] eVarArr = N;
        this.g0 = new HashMap[eVarArr.length];
        this.h0 = new HashSet(eVarArr.length);
        this.i0 = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(str, "filename cannot be null");
        FileInputStream fileInputStream2 = null;
        this.d0 = null;
        this.b0 = str;
        try {
            fileInputStream = new FileInputStream(str);
        } catch (Throwable th) {
            th = th;
        }
        try {
            if (B(fileInputStream.getFD())) {
                this.c0 = fileInputStream.getFD();
            } else {
                this.c0 = null;
            }
            D(fileInputStream);
            d(fileInputStream);
        } catch (Throwable th2) {
            th = th2;
            fileInputStream2 = fileInputStream;
            d(fileInputStream2);
            throw th;
        }
    }

    public static boolean B(FileDescriptor fileDescriptor) {
        try {
            Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_CUR);
            return true;
        } catch (Exception unused) {
            if (a) {
                Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                return false;
            }
            return false;
        }
    }

    public static boolean Q(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 sb = new StringBuilder(bArr.length * 2);
        for (int i2 = 0; i2 < bArr.length; i2++) {
            sb.append(String.format("%02x", Byte.valueOf(bArr[i2])));
        }
        return sb.toString();
    }

    public static void c(FileDescriptor fileDescriptor) {
        try {
            Os.close(fileDescriptor);
        } catch (Exception unused) {
            Log.e("ExifInterface", "Error closing fd.");
        }
    }

    public static void d(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (RuntimeException e2) {
                throw e2;
            } catch (Exception unused) {
            }
        }
    }

    public static double e(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[] f(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 g(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 h(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;
                ((c) outputStream).f2758d.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> z(String str) {
        if (str.contains(",")) {
            String[] split = str.split(",", -1);
            Pair<Integer, Integer> z2 = z(split[0]);
            if (((Integer) z2.first).intValue() == 2) {
                return z2;
            }
            for (int i2 = 1; i2 < split.length; i2++) {
                Pair<Integer, Integer> z3 = z(split[i2]);
                int intValue = (((Integer) z3.first).equals(z2.first) || ((Integer) z3.second).equals(z2.first)) ? ((Integer) z2.first).intValue() : -1;
                int intValue2 = (((Integer) z2.second).intValue() == -1 || !(((Integer) z3.first).equals(z2.second) || ((Integer) z3.second).equals(z2.second))) ? -1 : ((Integer) z2.second).intValue();
                if (intValue == -1 && intValue2 == -1) {
                    return new Pair<>(2, -1);
                }
                if (intValue == -1) {
                    z2 = new Pair<>(Integer.valueOf(intValue2), -1);
                } else if (intValue2 == -1) {
                    z2 = new Pair<>(Integer.valueOf(intValue), -1);
                }
            }
            return z2;
        } 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() <= WebSocketProtocol.PAYLOAD_SHORT_MAX) {
                        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 final void A(b bVar, HashMap hashMap) {
        d dVar = (d) hashMap.get("JPEGInterchangeFormat");
        d dVar2 = (d) hashMap.get("JPEGInterchangeFormatLength");
        if (dVar == null || dVar2 == null) {
            return;
        }
        int h2 = dVar.h(this.i0);
        int h3 = dVar2.h(this.i0);
        if (this.e0 == 7) {
            h2 += this.q0;
        }
        int min = Math.min(h3, bVar.o - h2);
        if (h2 > 0 && min > 0) {
            this.j0 = true;
            if (this.b0 == null && this.d0 == null && this.c0 == null) {
                byte[] bArr = new byte[min];
                bVar.skip(h2);
                bVar.read(bArr);
                this.n0 = bArr;
            }
            this.l0 = h2;
            this.m0 = min;
        }
        if (a) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + h2 + ", length: " + min);
        }
    }

    public final boolean C(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.i0) <= 512 && dVar2.h(this.i0) <= 512;
    }

    public final void D(InputStream inputStream) {
        for (int i2 = 0; i2 < N.length; i2++) {
            try {
                try {
                    this.g0[i2] = new HashMap<>();
                } catch (IOException e2) {
                    boolean z2 = a;
                    if (z2) {
                        Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e2);
                    }
                    a();
                    if (!z2) {
                        return;
                    }
                }
            } finally {
                a();
                if (a) {
                    F();
                }
            }
        }
        if (!this.f0) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            this.e0 = q(bufferedInputStream);
            inputStream = bufferedInputStream;
        }
        b bVar = new b(inputStream, ByteOrder.BIG_ENDIAN);
        if (!this.f0) {
            switch (this.e0) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    u(bVar);
                    break;
                case 4:
                    p(bVar, 0, 0);
                    a();
                    if (a) {
                        F();
                        return;
                    }
                    return;
                case 7:
                    r(bVar);
                    break;
                case 9:
                    t(bVar);
                    a();
                    if (a) {
                        F();
                        return;
                    }
                    return;
                case 10:
                    v(bVar);
                    a();
                    if (a) {
                        F();
                        return;
                    }
                    return;
                case 12:
                    o(bVar);
                    break;
                case 13:
                    s(bVar);
                    a();
                    if (a) {
                        F();
                        return;
                    }
                    return;
                case 14:
                    y(bVar);
                    a();
                    if (a) {
                        F();
                        return;
                    }
                    return;
            }
        } else {
            w(bVar);
        }
        bVar.b(this.p0);
        P(bVar);
    }

    public final void E(b bVar, int i2) {
        ByteOrder G2 = G(bVar);
        this.i0 = G2;
        bVar.n = G2;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i3 = this.e0;
        if (i3 != 7 && i3 != 10 && readUnsignedShort != 42) {
            StringBuilder O2 = e.a.a.a.a.O("Invalid start code: ");
            O2.append(Integer.toHexString(readUnsignedShort));
            throw new IOException(O2.toString());
        }
        int readInt = bVar.readInt();
        if (readInt >= 8 && readInt < i2) {
            int i4 = readInt - 8;
            if (i4 > 0 && bVar.skipBytes(i4) != i4) {
                throw new IOException(e.a.a.a.a.v("Couldn't jump to first Ifd: ", i4));
            }
            return;
        }
        throw new IOException(e.a.a.a.a.v("Invalid first Ifd offset: ", readInt));
    }

    public final void F() {
        for (int i2 = 0; i2 < this.g0.length; i2++) {
            StringBuilder P2 = e.a.a.a.a.P("The size of tag group[", i2, "]: ");
            P2.append(this.g0[i2].size());
            Log.d("ExifInterface", P2.toString());
            for (Map.Entry<String, d> entry : this.g0[i2].entrySet()) {
                d value = entry.getValue();
                StringBuilder O2 = e.a.a.a.a.O("tagName: ");
                O2.append(entry.getKey());
                O2.append(", tagType: ");
                O2.append(value.toString());
                O2.append(", tagValue: '");
                O2.append(value.i(this.i0));
                O2.append("'");
                Log.d("ExifInterface", O2.toString());
            }
        }
    }

    public final ByteOrder G(b bVar) {
        short readShort = bVar.readShort();
        if (readShort == 18761) {
            if (a) {
                Log.d("ExifInterface", "readExifSegment: Byte Align II");
            }
            return ByteOrder.LITTLE_ENDIAN;
        } else if (readShort == 19789) {
            if (a) {
                Log.d("ExifInterface", "readExifSegment: Byte Align MM");
            }
            return ByteOrder.BIG_ENDIAN;
        } else {
            StringBuilder O2 = e.a.a.a.a.O("Invalid byte order: ");
            O2.append(Integer.toHexString(readShort));
            throw new IOException(O2.toString());
        }
    }

    public final void H(byte[] bArr, int i2) {
        b bVar = new b(bArr);
        E(bVar, bArr.length);
        I(bVar, i2);
    }

    public final void I(b bVar, int i2) {
        short s2;
        short s3;
        int[] iArr;
        boolean z2;
        long j2;
        boolean z3;
        int i3;
        long j3;
        int i4;
        int i5;
        e eVar;
        long j4;
        int readUnsignedShort;
        long j5;
        int i6 = i2;
        this.h0.add(Integer.valueOf(bVar.p));
        if (bVar.p + 2 > bVar.o) {
            return;
        }
        short readShort = bVar.readShort();
        if (a) {
            e.a.a.a.a.p0("numberOfDirectoryEntry: ", readShort, "ExifInterface");
        }
        if ((readShort * 12) + bVar.p > bVar.o || readShort <= 0) {
            return;
        }
        char c2 = 0;
        short s4 = 0;
        while (s4 < readShort) {
            int readUnsignedShort2 = bVar.readUnsignedShort();
            int readUnsignedShort3 = bVar.readUnsignedShort();
            int readInt = bVar.readInt();
            long j6 = bVar.p + 4;
            e eVar2 = R[i6].get(Integer.valueOf(readUnsignedShort2));
            boolean z4 = a;
            if (z4) {
                Object[] objArr = new Object[5];
                objArr[c2] = Integer.valueOf(i2);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                objArr[2] = eVar2 != null ? eVar2.f2763b : null;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d("ExifInterface", String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            }
            if (eVar2 == null) {
                if (z4) {
                    e.a.a.a.a.p0("Skip the tag entry since tag number is not defined: ", readUnsignedShort2, "ExifInterface");
                }
                s2 = readShort;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < B.length) {
                        int i7 = eVar2.f2764c;
                        if (i7 == 7 || readUnsignedShort3 == 7 || i7 == readUnsignedShort3 || (i3 = eVar2.f2765d) == readUnsignedShort3) {
                            s2 = readShort;
                        } else {
                            s2 = readShort;
                            if (((i7 != 4 && i3 != 4) || readUnsignedShort3 != 3) && (((i7 != 9 && i3 != 9) || readUnsignedShort3 != 8) && ((i7 != 12 && i3 != 12) || readUnsignedShort3 != 11))) {
                                z2 = false;
                                if (!z2) {
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i7;
                                    }
                                    s3 = s4;
                                    j2 = readInt * iArr[readUnsignedShort3];
                                    if (j2 < 0 || j2 > 2147483647L) {
                                        if (z4) {
                                            e.a.a.a.a.p0("Skip the tag entry since the number of components is invalid: ", readInt, "ExifInterface");
                                        }
                                        z3 = false;
                                    } else {
                                        z3 = true;
                                    }
                                    if (!z3) {
                                        bVar.b(j6);
                                    } else {
                                        if (j2 > 4) {
                                            int readInt2 = bVar.readInt();
                                            if (z4) {
                                                e.a.a.a.a.p0("seek to data offset: ", readInt2, "ExifInterface");
                                            }
                                            i4 = readUnsignedShort3;
                                            if (this.e0 == 7) {
                                                if ("MakerNote".equals(eVar2.f2763b)) {
                                                    this.q0 = readInt2;
                                                } else if (i6 == 6 && "ThumbnailImage".equals(eVar2.f2763b)) {
                                                    this.r0 = readInt2;
                                                    this.s0 = readInt;
                                                    d e2 = d.e(6, this.i0);
                                                    eVar = eVar2;
                                                    d b2 = d.b(this.r0, this.i0);
                                                    i5 = readInt;
                                                    d b3 = d.b(this.s0, this.i0);
                                                    this.g0[4].put("Compression", e2);
                                                    this.g0[4].put("JPEGInterchangeFormat", b2);
                                                    this.g0[4].put("JPEGInterchangeFormatLength", b3);
                                                    j5 = readInt2;
                                                    j3 = j2;
                                                    if (j5 + j2 > bVar.o) {
                                                        bVar.b(j5);
                                                    } else {
                                                        if (z4) {
                                                            e.a.a.a.a.p0("Skip the tag entry since data offset is invalid: ", readInt2, "ExifInterface");
                                                        }
                                                        bVar.b(j6);
                                                    }
                                                }
                                            }
                                            i5 = readInt;
                                            eVar = eVar2;
                                            j5 = readInt2;
                                            j3 = j2;
                                            if (j5 + j2 > bVar.o) {
                                            }
                                        } else {
                                            j3 = j2;
                                            i4 = readUnsignedShort3;
                                            i5 = readInt;
                                            eVar = eVar2;
                                        }
                                        Integer num = U.get(Integer.valueOf(readUnsignedShort2));
                                        if (z4) {
                                            StringBuilder sb = new StringBuilder();
                                            sb.append("nextIfdType: ");
                                            sb.append(num);
                                            sb.append(" byteCount: ");
                                            j4 = j3;
                                            sb.append(j4);
                                            Log.d("ExifInterface", sb.toString());
                                        } else {
                                            j4 = j3;
                                        }
                                        if (num != null) {
                                            long j7 = -1;
                                            int i8 = i4;
                                            if (i8 == 3) {
                                                readUnsignedShort = bVar.readUnsignedShort();
                                            } else {
                                                if (i8 == 4) {
                                                    j7 = bVar.a();
                                                } else if (i8 == 8) {
                                                    readUnsignedShort = bVar.readShort();
                                                } else if (i8 == 9 || i8 == 13) {
                                                    readUnsignedShort = bVar.readInt();
                                                }
                                                if (z4) {
                                                    Log.d("ExifInterface", String.format("Offset: %d, tagName: %s", Long.valueOf(j7), eVar.f2763b));
                                                }
                                                if (j7 > 0 || j7 >= bVar.o) {
                                                    if (z4) {
                                                        Log.d("ExifInterface", "Skip jump into the IFD since its offset is invalid: " + j7);
                                                    }
                                                } else if (!this.h0.contains(Integer.valueOf((int) j7))) {
                                                    bVar.b(j7);
                                                    I(bVar, num.intValue());
                                                } else if (z4) {
                                                    Log.d("ExifInterface", "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j7 + ")");
                                                }
                                                bVar.b(j6);
                                            }
                                            j7 = readUnsignedShort;
                                            if (z4) {
                                            }
                                            if (j7 > 0) {
                                            }
                                            if (z4) {
                                            }
                                            bVar.b(j6);
                                        } else {
                                            e eVar3 = eVar;
                                            int i9 = bVar.p + this.p0;
                                            byte[] bArr = new byte[(int) j4];
                                            bVar.readFully(bArr);
                                            d dVar = new d(i4, i5, i9, bArr);
                                            this.g0[i2].put(eVar3.f2763b, dVar);
                                            if ("DNGVersion".equals(eVar3.f2763b)) {
                                                this.e0 = 3;
                                            }
                                            if ((("Make".equals(eVar3.f2763b) || "Model".equals(eVar3.f2763b)) && dVar.i(this.i0).contains("PENTAX")) || ("Compression".equals(eVar3.f2763b) && dVar.h(this.i0) == 65535)) {
                                                this.e0 = 8;
                                            }
                                            if (bVar.p != j6) {
                                                bVar.b(j6);
                                            }
                                        }
                                    }
                                    s4 = (short) (s3 + 1);
                                    c2 = 0;
                                    i6 = i2;
                                    readShort = s2;
                                } else if (z4) {
                                    StringBuilder O2 = e.a.a.a.a.O("Skip the tag entry since data format (");
                                    O2.append(A[readUnsignedShort3]);
                                    O2.append(") is unexpected for tag: ");
                                    O2.append(eVar2.f2763b);
                                    Log.d("ExifInterface", O2.toString());
                                }
                            }
                        }
                        z2 = true;
                        if (!z2) {
                        }
                    }
                }
                s2 = readShort;
                s3 = s4;
                if (z4) {
                    e.a.a.a.a.p0("Skip the tag entry since data format is invalid: ", readUnsignedShort3, "ExifInterface");
                }
                z3 = false;
                j2 = 0;
                if (!z3) {
                }
                s4 = (short) (s3 + 1);
                c2 = 0;
                i6 = i2;
                readShort = s2;
            }
            s3 = s4;
            z3 = false;
            j2 = 0;
            if (!z3) {
            }
            s4 = (short) (s3 + 1);
            c2 = 0;
            i6 = i2;
            readShort = s2;
        }
        if (bVar.p + 4 <= bVar.o) {
            int readInt3 = bVar.readInt();
            boolean z5 = a;
            if (z5) {
                Log.d("ExifInterface", String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
            }
            long j8 = readInt3;
            if (j8 <= 0 || readInt3 >= bVar.o) {
                if (z5) {
                    e.a.a.a.a.p0("Stop reading file since a wrong offset may cause an infinite loop: ", readInt3, "ExifInterface");
                }
            } else if (this.h0.contains(Integer.valueOf(readInt3))) {
                if (z5) {
                    e.a.a.a.a.p0("Stop reading file since re-reading an IFD may cause an infinite loop: ", readInt3, "ExifInterface");
                }
            } else {
                bVar.b(j8);
                if (this.g0[4].isEmpty()) {
                    I(bVar, 4);
                } else if (this.g0[5].isEmpty()) {
                    I(bVar, 5);
                }
            }
        }
    }

    public final void J(String str) {
        for (int i2 = 0; i2 < N.length; i2++) {
            this.g0[i2].remove(str);
        }
    }

    public void K() {
        FileOutputStream fileOutputStream;
        File createTempFile;
        FileInputStream fileInputStream;
        Closeable closeable;
        FileOutputStream fileOutputStream2;
        FileInputStream fileInputStream2;
        FileOutputStream fileOutputStream3;
        FileInputStream fileInputStream3;
        Object obj;
        int i2 = this.e0;
        if (i2 == 4 || i2 == 13 || i2 == 14) {
            if (this.c0 == null && this.b0 == null) {
                throw new IOException("ExifInterface does not support saving attributes for the current input.");
            }
            int i3 = this.o0;
            BufferedInputStream bufferedInputStream = null;
            this.n0 = (i3 == 6 || i3 == 7) ? x() : null;
            try {
                createTempFile = File.createTempFile("temp", "tmp");
                if (this.b0 != null) {
                    fileInputStream = new FileInputStream(this.b0);
                } else {
                    Os.lseek(this.c0, 0L, OsConstants.SEEK_SET);
                    fileInputStream = new FileInputStream(this.c0);
                }
                try {
                    fileOutputStream = new FileOutputStream(createTempFile);
                } catch (Exception e2) {
                    e = e2;
                    fileOutputStream = null;
                } catch (Throwable th) {
                    th = th;
                    fileOutputStream = null;
                }
            } catch (Exception e3) {
                e = e3;
                fileOutputStream = null;
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = null;
            }
            try {
                g(fileInputStream, fileOutputStream);
                d(fileInputStream);
                d(fileOutputStream);
                try {
                } catch (Throwable th3) {
                    th = th3;
                }
                try {
                    try {
                        fileInputStream3 = new FileInputStream(createTempFile);
                        try {
                            if (this.b0 != null) {
                                fileOutputStream2 = new FileOutputStream(this.b0);
                            } else {
                                Os.lseek(this.c0, 0L, OsConstants.SEEK_SET);
                                fileOutputStream2 = new FileOutputStream(this.c0);
                            }
                        } catch (Exception e4) {
                            e = e4;
                            fileOutputStream2 = null;
                            obj = null;
                        }
                    } catch (Throwable th4) {
                        th = th4;
                        closeable = null;
                        d(bufferedInputStream);
                        d(closeable);
                        if (0 == 0) {
                            createTempFile.delete();
                        }
                        throw th;
                    }
                    try {
                        BufferedInputStream bufferedInputStream2 = new BufferedInputStream(fileInputStream3);
                        try {
                            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream2);
                            try {
                                int i4 = this.e0;
                                if (i4 == 4) {
                                    L(bufferedInputStream2, bufferedOutputStream);
                                } else if (i4 == 13) {
                                    M(bufferedInputStream2, bufferedOutputStream);
                                } else if (i4 == 14) {
                                    N(bufferedInputStream2, bufferedOutputStream);
                                }
                                d(bufferedInputStream2);
                                d(bufferedOutputStream);
                                createTempFile.delete();
                                this.n0 = null;
                            } catch (Exception e5) {
                                e = e5;
                                bufferedInputStream = fileInputStream3;
                                try {
                                    fileInputStream2 = new FileInputStream(createTempFile);
                                } catch (Exception e6) {
                                    e = e6;
                                } catch (Throwable th5) {
                                    th = th5;
                                }
                                try {
                                    if (this.b0 != null) {
                                        Os.lseek(this.c0, 0L, OsConstants.SEEK_SET);
                                        fileOutputStream3 = new FileOutputStream(this.c0);
                                    } else {
                                        fileOutputStream3 = new FileOutputStream(this.b0);
                                    }
                                    fileOutputStream2 = fileOutputStream3;
                                    g(fileInputStream2, fileOutputStream2);
                                    d(fileInputStream2);
                                    d(fileOutputStream2);
                                    throw new IOException("Failed to save new file", e);
                                } catch (Exception e7) {
                                    e = e7;
                                    bufferedInputStream = fileInputStream2;
                                    try {
                                        throw new IOException("Failed to save new file. Original file is stored in " + createTempFile.getAbsolutePath(), e);
                                    } catch (Throwable th6) {
                                        th = th6;
                                        d(bufferedInputStream);
                                        d(fileOutputStream2);
                                        throw th;
                                    }
                                } catch (Throwable th7) {
                                    th = th7;
                                    bufferedInputStream = fileInputStream2;
                                    d(bufferedInputStream);
                                    d(fileOutputStream2);
                                    throw th;
                                }
                            }
                        } catch (Exception e8) {
                            e = e8;
                        } catch (Throwable th8) {
                            th = th8;
                            closeable = null;
                            bufferedInputStream = bufferedInputStream2;
                            d(bufferedInputStream);
                            d(closeable);
                            if (0 == 0) {
                            }
                            throw th;
                        }
                    } catch (Exception e9) {
                        e = e9;
                        obj = null;
                        bufferedInputStream = fileInputStream3;
                        fileInputStream2 = new FileInputStream(createTempFile);
                        if (this.b0 != null) {
                        }
                        fileOutputStream2 = fileOutputStream3;
                        g(fileInputStream2, fileOutputStream2);
                        d(fileInputStream2);
                        d(fileOutputStream2);
                        throw new IOException("Failed to save new file", e);
                    }
                } catch (Exception e10) {
                    e = e10;
                    fileOutputStream2 = null;
                }
            } catch (Exception e11) {
                e = e11;
                bufferedInputStream = fileInputStream;
                try {
                    throw new IOException("Failed to copy original file to temp file", e);
                } catch (Throwable th9) {
                    th = th9;
                    d(bufferedInputStream);
                    d(fileOutputStream);
                    throw th;
                }
            } catch (Throwable th10) {
                th = th10;
                bufferedInputStream = fileInputStream;
                d(bufferedInputStream);
                d(fileOutputStream);
                throw th;
            }
        } else {
            throw new IOException("ExifInterface only supports saving attributes on JPEG, PNG, or WebP formats.");
        }
    }

    public final void L(InputStream inputStream, OutputStream outputStream) {
        if (a) {
            Log.d("ExifInterface", "saveJpegAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        DataInputStream dataInputStream = new DataInputStream(inputStream);
        c cVar = new c(outputStream, ByteOrder.BIG_ENDIAN);
        if (dataInputStream.readByte() == -1) {
            cVar.f2758d.write(-1);
            if (dataInputStream.readByte() == -40) {
                cVar.f2758d.write(-40);
                d dVar = null;
                if (k("Xmp") != null && this.t0) {
                    dVar = this.g0[0].remove("Xmp");
                }
                cVar.f2758d.write(-1);
                cVar.f2758d.write(-31);
                U(cVar);
                if (dVar != null) {
                    this.g0[0].put("Xmp", dVar);
                }
                byte[] bArr = new byte[4096];
                while (dataInputStream.readByte() == -1) {
                    byte readByte = dataInputStream.readByte();
                    if (readByte == -39 || readByte == -38) {
                        cVar.f2758d.write(-1);
                        cVar.f2758d.write(readByte);
                        g(dataInputStream, cVar);
                        return;
                    } else if (readByte != -31) {
                        cVar.f2758d.write(-1);
                        cVar.f2758d.write(readByte);
                        int readUnsignedShort = dataInputStream.readUnsignedShort();
                        cVar.b((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.f2758d.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, W)) {
                                        int i3 = readUnsignedShort2 - 6;
                                        if (dataInputStream.skipBytes(i3) != i3) {
                                            throw new IOException("Invalid length");
                                        }
                                    }
                                } else {
                                    throw new IOException("Invalid exif");
                                }
                            }
                            cVar.f2758d.write(-1);
                            cVar.f2758d.write(readByte);
                            cVar.b((short) (readUnsignedShort2 + 2));
                            if (readUnsignedShort2 >= 6) {
                                readUnsignedShort2 -= 6;
                                cVar.f2758d.write(bArr2);
                            }
                            while (readUnsignedShort2 > 0) {
                                int read2 = dataInputStream.read(bArr, 0, Math.min(readUnsignedShort2, 4096));
                                if (read2 >= 0) {
                                    cVar.f2758d.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 M(InputStream inputStream, OutputStream outputStream) {
        ByteArrayOutputStream byteArrayOutputStream;
        if (a) {
            Log.d("ExifInterface", "savePngAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        DataInputStream dataInputStream = new DataInputStream(inputStream);
        ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
        c cVar = new c(outputStream, byteOrder);
        byte[] bArr = f2751l;
        h(dataInputStream, cVar, bArr.length);
        int i2 = this.p0;
        if (i2 == 0) {
            int readInt = dataInputStream.readInt();
            cVar.a(readInt);
            h(dataInputStream, cVar, readInt + 4 + 4);
        } else {
            h(dataInputStream, cVar, ((i2 - bArr.length) - 4) - 4);
            dataInputStream.skipBytes(dataInputStream.readInt() + 4 + 4);
        }
        ByteArrayOutputStream byteArrayOutputStream2 = null;
        try {
            byteArrayOutputStream = new ByteArrayOutputStream();
        } catch (Throwable th) {
            th = th;
        }
        try {
            c cVar2 = new c(byteArrayOutputStream, byteOrder);
            U(cVar2);
            byte[] byteArray = ((ByteArrayOutputStream) cVar2.f2758d).toByteArray();
            cVar.f2758d.write(byteArray);
            CRC32 crc32 = new CRC32();
            crc32.update(byteArray, 4, byteArray.length - 4);
            cVar.a((int) crc32.getValue());
            d(byteArrayOutputStream);
            g(dataInputStream, cVar);
        } catch (Throwable th2) {
            th = th2;
            byteArrayOutputStream2 = byteArrayOutputStream;
            d(byteArrayOutputStream2);
            throw th;
        }
    }

    public final void N(InputStream inputStream, OutputStream outputStream) {
        ByteArrayOutputStream byteArrayOutputStream;
        int i2;
        int i3;
        int i4;
        int readInt;
        int i5;
        int i6;
        int i7;
        if (a) {
            Log.d("ExifInterface", "saveWebpAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
        b bVar = new b(inputStream, byteOrder);
        c cVar = new c(outputStream, byteOrder);
        byte[] bArr = p;
        h(bVar, cVar, bArr.length);
        byte[] bArr2 = q;
        bVar.skipBytes(bArr2.length + 4);
        ByteArrayOutputStream byteArrayOutputStream2 = null;
        try {
            try {
                byteArrayOutputStream = new ByteArrayOutputStream();
            } catch (Exception e2) {
                e = e2;
            }
        } catch (Throwable th) {
            th = th;
            byteArrayOutputStream = byteArrayOutputStream2;
        }
        try {
            c cVar2 = new c(byteArrayOutputStream, byteOrder);
            int i8 = this.p0;
            if (i8 != 0) {
                h(bVar, cVar2, ((i8 - ((bArr.length + 4) + bArr2.length)) - 4) - 4);
                bVar.skipBytes(4);
                bVar.skipBytes(bVar.readInt());
                U(cVar2);
            } else {
                byte[] bArr3 = new byte[4];
                if (bVar.read(bArr3) == 4) {
                    byte[] bArr4 = t;
                    boolean z2 = 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) {
                            z2 = false;
                        }
                        cVar2.f2758d.write(bArr4);
                        cVar2.a(readInt2);
                        cVar2.f2758d.write(bArr5);
                        if (z2) {
                            i(bVar, cVar2, w, null);
                            while (true) {
                                byte[] bArr6 = new byte[4];
                                inputStream.read(bArr6);
                                if (!Arrays.equals(bArr6, x)) {
                                    break;
                                }
                                j(bVar, cVar2, bArr6);
                            }
                            U(cVar2);
                        } else {
                            i(bVar, cVar2, v, u);
                            U(cVar2);
                        }
                    } else {
                        byte[] bArr7 = v;
                        if (Arrays.equals(bArr3, bArr7) || Arrays.equals(bArr3, u)) {
                            int readInt3 = bVar.readInt();
                            int i9 = 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(s, bArr9)) {
                                    i2 = bVar.readInt();
                                    i3 = (i2 << 18) >> 18;
                                    i4 = (i2 << 2) >> 18;
                                    i9 -= 10;
                                } else {
                                    throw new IOException("Encountered error while checking VP8 signature");
                                }
                            } else if (!Arrays.equals(bArr3, u)) {
                                i2 = 0;
                                i3 = 0;
                                i4 = 0;
                            } else if (bVar.readByte() == 47) {
                                readInt = bVar.readInt();
                                i5 = ((readInt << 18) >> 18) + 1;
                                i6 = ((readInt << 4) >> 18) + 1;
                                i7 = readInt & 8;
                                i9 -= 5;
                                cVar2.f2758d.write(bArr4);
                                cVar2.a(10);
                                byte[] bArr10 = new byte[10];
                                bArr10[0] = (byte) (bArr10[0] | 8);
                                bArr10[0] = (byte) (bArr10[0] | (i7 << 4));
                                int i10 = i5 - 1;
                                int i11 = i6 - 1;
                                bArr10[4] = (byte) i10;
                                bArr10[5] = (byte) (i10 >> 8);
                                bArr10[6] = (byte) (i10 >> 16);
                                bArr10[7] = (byte) i11;
                                bArr10[8] = (byte) (i11 >> 8);
                                bArr10[9] = (byte) (i11 >> 16);
                                cVar2.f2758d.write(bArr10);
                                cVar2.f2758d.write(bArr3);
                                cVar2.a(readInt3);
                                if (!Arrays.equals(bArr3, bArr7)) {
                                    cVar2.f2758d.write(bArr8);
                                    cVar2.f2758d.write(s);
                                    cVar2.a(readInt);
                                } else if (Arrays.equals(bArr3, u)) {
                                    cVar2.write(47);
                                    cVar2.a(readInt);
                                }
                                h(bVar, cVar2, i9);
                                U(cVar2);
                            } else {
                                throw new IOException("Encountered error while checking VP8L signature");
                            }
                            i6 = i4;
                            i5 = i3;
                            readInt = i2;
                            i7 = 0;
                            cVar2.f2758d.write(bArr4);
                            cVar2.a(10);
                            byte[] bArr102 = new byte[10];
                            bArr102[0] = (byte) (bArr102[0] | 8);
                            bArr102[0] = (byte) (bArr102[0] | (i7 << 4));
                            int i102 = i5 - 1;
                            int i112 = i6 - 1;
                            bArr102[4] = (byte) i102;
                            bArr102[5] = (byte) (i102 >> 8);
                            bArr102[6] = (byte) (i102 >> 16);
                            bArr102[7] = (byte) i112;
                            bArr102[8] = (byte) (i112 >> 8);
                            bArr102[9] = (byte) (i112 >> 16);
                            cVar2.f2758d.write(bArr102);
                            cVar2.f2758d.write(bArr3);
                            cVar2.a(readInt3);
                            if (!Arrays.equals(bArr3, bArr7)) {
                            }
                            h(bVar, cVar2, i9);
                            U(cVar2);
                        }
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing WebP chunk type");
                }
            }
            g(bVar, cVar2);
            int size = byteArrayOutputStream.size();
            byte[] bArr11 = q;
            cVar.a(size + bArr11.length);
            cVar.f2758d.write(bArr11);
            byteArrayOutputStream.writeTo(cVar);
            d(byteArrayOutputStream);
        } catch (Exception e3) {
            e = e3;
            byteArrayOutputStream2 = byteArrayOutputStream;
            throw new IOException("Failed to save WebP file", e);
        } catch (Throwable th2) {
            th = th2;
            d(byteArrayOutputStream);
            throw th;
        }
    }

    public void O(String str, String str2) {
        e eVar;
        int i2;
        d dVar;
        String sb;
        Matcher matcher;
        String str3 = str;
        String str4 = str2;
        if (("DateTime".equals(str3) || "DateTimeOriginal".equals(str3) || "DateTimeDigitized".equals(str3)) && str4 != null) {
            boolean find = Z.matcher(str4).find();
            boolean find2 = a0.matcher(str4).find();
            if (str2.length() != 19 || (!find && !find2)) {
                Log.w("ExifInterface", "Invalid value for " + str3 + " : " + str4);
                return;
            } else if (find2) {
                str4 = str4.replaceAll("-", ":");
            }
        }
        if ("ISOSpeedRatings".equals(str3)) {
            if (a) {
                Log.d("ExifInterface", "setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str3 = "PhotographicSensitivity";
        }
        int i3 = 2;
        int i4 = 1;
        if (str4 != null && T.contains(str3)) {
            if (str3.equals("GPSTimeStamp")) {
                if (!Y.matcher(str4).find()) {
                    Log.w("ExifInterface", "Invalid value for " + str3 + " : " + str4);
                    return;
                }
                str4 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1";
            } else {
                try {
                    str4 = new f(Double.parseDouble(str4)).toString();
                } catch (NumberFormatException unused) {
                    Log.w("ExifInterface", "Invalid value for " + str3 + " : " + str4);
                    return;
                }
            }
        }
        char c2 = 0;
        int i5 = 0;
        while (i5 < N.length) {
            if ((i5 != 4 || this.j0) && (eVar = S[i5].get(str3)) != null) {
                if (str4 == null) {
                    this.g0[i5].remove(str3);
                } else {
                    Pair<Integer, Integer> z2 = z(str4);
                    int i6 = -1;
                    if (eVar.f2764c != ((Integer) z2.first).intValue() && eVar.f2764c != ((Integer) z2.second).intValue()) {
                        int i7 = eVar.f2765d;
                        if (i7 != -1 && (i7 == ((Integer) z2.first).intValue() || eVar.f2765d == ((Integer) z2.second).intValue())) {
                            i2 = eVar.f2765d;
                        } else {
                            int i8 = eVar.f2764c;
                            if (i8 == i4 || i8 == 7 || i8 == i3) {
                                i2 = i8;
                            } else if (a) {
                                StringBuilder U2 = e.a.a.a.a.U("Given tag (", str3, ") value didn't match with one of expected formats: ");
                                String[] strArr = A;
                                U2.append(strArr[eVar.f2764c]);
                                String str5 = "";
                                if (eVar.f2765d == -1) {
                                    sb = "";
                                } else {
                                    StringBuilder O2 = e.a.a.a.a.O(", ");
                                    O2.append(strArr[eVar.f2765d]);
                                    sb = O2.toString();
                                }
                                U2.append(sb);
                                U2.append(" (guess: ");
                                U2.append(strArr[((Integer) z2.first).intValue()]);
                                if (((Integer) z2.second).intValue() != -1) {
                                    StringBuilder O3 = e.a.a.a.a.O(", ");
                                    O3.append(strArr[((Integer) z2.second).intValue()]);
                                    str5 = O3.toString();
                                }
                                U2.append(str5);
                                U2.append(")");
                                Log.d("ExifInterface", U2.toString());
                            }
                        }
                    } else {
                        i2 = eVar.f2764c;
                    }
                    switch (i2) {
                        case 1:
                            HashMap<String, d> hashMap = this.g0[i5];
                            i4 = 1;
                            if (str4.length() == 1) {
                                c2 = 0;
                                if (str4.charAt(0) >= '0' && str4.charAt(0) <= '1') {
                                    dVar = new d(1, 1, new byte[]{(byte) (str4.charAt(0) - '0')});
                                    hashMap.put(str3, dVar);
                                    break;
                                }
                            } else {
                                c2 = 0;
                            }
                            byte[] bytes = str4.getBytes(V);
                            dVar = new d(1, bytes.length, bytes);
                            hashMap.put(str3, dVar);
                            break;
                        case 2:
                        case 7:
                            this.g0[i5].put(str3, d.a(str4));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 3:
                            String[] split = str4.split(",", -1);
                            int[] iArr = new int[split.length];
                            for (int i9 = 0; i9 < split.length; i9++) {
                                iArr[i9] = Integer.parseInt(split[i9]);
                            }
                            this.g0[i5].put(str3, d.f(iArr, this.i0));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 4:
                            String[] split2 = str4.split(",", -1);
                            long[] jArr = new long[split2.length];
                            for (int i10 = 0; i10 < split2.length; i10++) {
                                jArr[i10] = Long.parseLong(split2[i10]);
                            }
                            this.g0[i5].put(str3, d.c(jArr, this.i0));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 5:
                            int i11 = -1;
                            String[] split3 = str4.split(",", -1);
                            f[] fVarArr = new f[split3.length];
                            int i12 = 0;
                            while (i12 < split3.length) {
                                String[] split4 = split3[i12].split("/", i11);
                                fVarArr[i12] = new f((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1]));
                                i12++;
                                i11 = -1;
                            }
                            this.g0[i5].put(str3, d.d(fVarArr, this.i0));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 6:
                        case 8:
                        case 11:
                        default:
                            if (a) {
                                e.a.a.a.a.p0("Data format isn't one of expected formats: ", i2, "ExifInterface");
                                break;
                            } else {
                                break;
                            }
                        case 9:
                            String[] split5 = str4.split(",", -1);
                            int length = split5.length;
                            int[] iArr2 = new int[length];
                            for (int i13 = 0; i13 < split5.length; i13++) {
                                iArr2[i13] = Integer.parseInt(split5[i13]);
                            }
                            HashMap<String, d> hashMap2 = this.g0[i5];
                            ByteOrder byteOrder = this.i0;
                            ByteBuffer wrap = ByteBuffer.wrap(new byte[B[9] * length]);
                            wrap.order(byteOrder);
                            for (int i14 = 0; i14 < length; i14++) {
                                wrap.putInt(iArr2[i14]);
                            }
                            hashMap2.put(str3, new d(9, length, wrap.array()));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 10:
                            String[] split6 = str4.split(",", -1);
                            int length2 = split6.length;
                            f[] fVarArr2 = new f[length2];
                            int i15 = 0;
                            while (i15 < split6.length) {
                                String[] split7 = split6[i15].split("/", i6);
                                fVarArr2[i15] = new f((long) Double.parseDouble(split7[c2]), (long) Double.parseDouble(split7[i4]));
                                i15++;
                                c2 = 0;
                                i4 = 1;
                                split6 = split6;
                                i6 = -1;
                            }
                            HashMap<String, d> hashMap3 = this.g0[i5];
                            ByteOrder byteOrder2 = this.i0;
                            ByteBuffer wrap2 = ByteBuffer.wrap(new byte[B[10] * length2]);
                            wrap2.order(byteOrder2);
                            for (int i16 = 0; i16 < length2; i16++) {
                                f fVar = fVarArr2[i16];
                                wrap2.putInt((int) fVar.a);
                                wrap2.putInt((int) fVar.f2766b);
                            }
                            hashMap3.put(str3, new d(10, length2, wrap2.array()));
                            c2 = 0;
                            i4 = 1;
                            break;
                        case 12:
                            String[] split8 = str4.split(",", -1);
                            int length3 = split8.length;
                            double[] dArr = new double[length3];
                            for (int i17 = 0; i17 < split8.length; i17++) {
                                dArr[i17] = Double.parseDouble(split8[i17]);
                            }
                            HashMap<String, d> hashMap4 = this.g0[i5];
                            ByteOrder byteOrder3 = this.i0;
                            ByteBuffer wrap3 = ByteBuffer.wrap(new byte[B[12] * length3]);
                            wrap3.order(byteOrder3);
                            for (int i18 = 0; i18 < length3; i18++) {
                                wrap3.putDouble(dArr[i18]);
                            }
                            hashMap4.put(str3, new d(12, length3, wrap3.array()));
                            break;
                    }
                }
            }
            i5++;
            i3 = 2;
        }
    }

    public final void P(b bVar) {
        boolean z2;
        d dVar;
        int h2;
        HashMap<String, d> hashMap = this.g0[4];
        d dVar2 = hashMap.get("Compression");
        if (dVar2 != null) {
            int h3 = dVar2.h(this.i0);
            this.o0 = h3;
            int i2 = 1;
            if (h3 != 1) {
                if (h3 == 6) {
                    A(bVar, hashMap);
                    return;
                } else if (h3 != 7) {
                    return;
                }
            }
            d dVar3 = hashMap.get("BitsPerSample");
            if (dVar3 != null) {
                int[] iArr = (int[]) dVar3.j(this.i0);
                int[] iArr2 = f2743d;
                if (Arrays.equals(iArr2, iArr) || (this.e0 == 3 && (dVar = hashMap.get("PhotometricInterpretation")) != null && (((h2 = dVar.h(this.i0)) == 1 && Arrays.equals(iArr, f2744e)) || (h2 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z2 = true;
                    if (z2) {
                        return;
                    }
                    d dVar4 = hashMap.get("StripOffsets");
                    d dVar5 = hashMap.get("StripByteCounts");
                    if (dVar4 == null || dVar5 == null) {
                        return;
                    }
                    long[] f2 = f(dVar4.j(this.i0));
                    long[] f3 = f(dVar5.j(this.i0));
                    if (f2 != null && f2.length != 0) {
                        if (f3 != null && f3.length != 0) {
                            if (f2.length != f3.length) {
                                Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                                return;
                            }
                            long j2 = 0;
                            for (long j3 : f3) {
                                j2 += j3;
                            }
                            int i3 = (int) j2;
                            byte[] bArr = new byte[i3];
                            this.k0 = true;
                            this.j0 = true;
                            int i4 = 0;
                            int i5 = 0;
                            int i6 = 0;
                            while (i4 < f2.length) {
                                int i7 = (int) f2[i4];
                                int i8 = (int) f3[i4];
                                if (i4 < f2.length - i2 && i7 + i8 != f2[i4 + 1]) {
                                    this.k0 = false;
                                }
                                int i9 = i7 - i5;
                                if (i9 < 0) {
                                    Log.d("ExifInterface", "Invalid strip offset value");
                                    return;
                                }
                                long j4 = i9;
                                if (bVar.skip(j4) != j4) {
                                    Log.d("ExifInterface", "Failed to skip " + i9 + " bytes.");
                                    return;
                                }
                                int i10 = i5 + i9;
                                byte[] bArr2 = new byte[i8];
                                if (bVar.read(bArr2) != i8) {
                                    Log.d("ExifInterface", "Failed to read " + i8 + " bytes.");
                                    return;
                                }
                                i5 = i10 + i8;
                                System.arraycopy(bArr2, 0, bArr, i6, i8);
                                i6 += i8;
                                i4++;
                                i2 = 1;
                            }
                            this.n0 = bArr;
                            if (this.k0) {
                                this.l0 = (int) f2[0];
                                this.m0 = i3;
                                return;
                            }
                            return;
                        }
                        Log.w("ExifInterface", "stripByteCounts should not be null or have zero length.");
                        return;
                    }
                    Log.w("ExifInterface", "stripOffsets should not be null or have zero length.");
                    return;
                }
            }
            if (a) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z2 = false;
            if (z2) {
            }
        } else {
            this.o0 = 6;
            A(bVar, hashMap);
        }
    }

    public final void R(int i2, int i3) {
        if (!this.g0[i2].isEmpty() && !this.g0[i3].isEmpty()) {
            d dVar = this.g0[i2].get("ImageLength");
            d dVar2 = this.g0[i2].get("ImageWidth");
            d dVar3 = this.g0[i3].get("ImageLength");
            d dVar4 = this.g0[i3].get("ImageWidth");
            if (dVar == null || dVar2 == null) {
                if (a) {
                    Log.d("ExifInterface", "First image does not contain valid size information");
                }
            } else if (dVar3 != null && dVar4 != null) {
                int h2 = dVar.h(this.i0);
                int h3 = dVar2.h(this.i0);
                int h4 = dVar3.h(this.i0);
                int h5 = dVar4.h(this.i0);
                if (h2 >= h4 || h3 >= h5) {
                    return;
                }
                HashMap<String, d>[] hashMapArr = this.g0;
                HashMap<String, d> hashMap = hashMapArr[i2];
                hashMapArr[i2] = hashMapArr[i3];
                hashMapArr[i3] = hashMap;
            } else if (a) {
                Log.d("ExifInterface", "Second image does not contain valid size information");
            }
        } else if (a) {
            Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
        }
    }

    public final void S(b bVar, int i2) {
        d e2;
        d e3;
        d dVar = this.g0[i2].get("DefaultCropSize");
        d dVar2 = this.g0[i2].get("SensorTopBorder");
        d dVar3 = this.g0[i2].get("SensorLeftBorder");
        d dVar4 = this.g0[i2].get("SensorBottomBorder");
        d dVar5 = this.g0[i2].get("SensorRightBorder");
        if (dVar != null) {
            if (dVar.a == 5) {
                f[] fVarArr = (f[]) dVar.j(this.i0);
                if (fVarArr != null && fVarArr.length == 2) {
                    e2 = d.d(new f[]{fVarArr[0]}, this.i0);
                    e3 = d.d(new f[]{fVarArr[1]}, this.i0);
                } else {
                    StringBuilder O2 = e.a.a.a.a.O("Invalid crop size values. cropSize=");
                    O2.append(Arrays.toString(fVarArr));
                    Log.w("ExifInterface", O2.toString());
                    return;
                }
            } else {
                int[] iArr = (int[]) dVar.j(this.i0);
                if (iArr != null && iArr.length == 2) {
                    e2 = d.e(iArr[0], this.i0);
                    e3 = d.e(iArr[1], this.i0);
                } else {
                    StringBuilder O3 = e.a.a.a.a.O("Invalid crop size values. cropSize=");
                    O3.append(Arrays.toString(iArr));
                    Log.w("ExifInterface", O3.toString());
                    return;
                }
            }
            this.g0[i2].put("ImageWidth", e2);
            this.g0[i2].put("ImageLength", e3);
        } else if (dVar2 != null && dVar3 != null && dVar4 != null && dVar5 != null) {
            int h2 = dVar2.h(this.i0);
            int h3 = dVar4.h(this.i0);
            int h4 = dVar5.h(this.i0);
            int h5 = dVar3.h(this.i0);
            if (h3 <= h2 || h4 <= h5) {
                return;
            }
            d e4 = d.e(h3 - h2, this.i0);
            d e5 = d.e(h4 - h5, this.i0);
            this.g0[i2].put("ImageLength", e4);
            this.g0[i2].put("ImageWidth", e5);
        } else {
            d dVar6 = this.g0[i2].get("ImageLength");
            d dVar7 = this.g0[i2].get("ImageWidth");
            if (dVar6 == null || dVar7 == null) {
                d dVar8 = this.g0[i2].get("JPEGInterchangeFormat");
                d dVar9 = this.g0[i2].get("JPEGInterchangeFormatLength");
                if (dVar8 == null || dVar9 == null) {
                    return;
                }
                int h6 = dVar8.h(this.i0);
                int h7 = dVar8.h(this.i0);
                bVar.b(h6);
                byte[] bArr = new byte[h7];
                bVar.read(bArr);
                p(new b(bArr), h6, i2);
            }
        }
    }

    public final void T() {
        R(0, 5);
        R(0, 4);
        R(5, 4);
        d dVar = this.g0[1].get("PixelXDimension");
        d dVar2 = this.g0[1].get("PixelYDimension");
        if (dVar != null && dVar2 != null) {
            this.g0[0].put("ImageWidth", dVar);
            this.g0[0].put("ImageLength", dVar2);
        }
        if (this.g0[4].isEmpty() && C(this.g0[5])) {
            HashMap<String, d>[] hashMapArr = this.g0;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (C(this.g0[4])) {
            return;
        }
        Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
    }

    public final int U(c cVar) {
        e[][] eVarArr = N;
        int[] iArr = new int[eVarArr.length];
        int[] iArr2 = new int[eVarArr.length];
        for (e eVar : O) {
            J(eVar.f2763b);
        }
        J(P.f2763b);
        J(Q.f2763b);
        for (int i2 = 0; i2 < N.length; i2++) {
            for (Object obj : this.g0[i2].entrySet().toArray()) {
                Map.Entry entry = (Map.Entry) obj;
                if (entry.getValue() == null) {
                    this.g0[i2].remove(entry.getKey());
                }
            }
        }
        if (!this.g0[1].isEmpty()) {
            this.g0[0].put(O[1].f2763b, d.b(0L, this.i0));
        }
        if (!this.g0[2].isEmpty()) {
            this.g0[0].put(O[2].f2763b, d.b(0L, this.i0));
        }
        if (!this.g0[3].isEmpty()) {
            this.g0[1].put(O[3].f2763b, d.b(0L, this.i0));
        }
        if (this.j0) {
            this.g0[4].put(P.f2763b, d.b(0L, this.i0));
            this.g0[4].put(Q.f2763b, d.b(this.m0, this.i0));
        }
        for (int i3 = 0; i3 < N.length; i3++) {
            int i4 = 0;
            for (Map.Entry<String, d> entry2 : this.g0[i3].entrySet()) {
                d value = entry2.getValue();
                Objects.requireNonNull(value);
                int i5 = B[value.a] * value.f2760b;
                if (i5 > 4) {
                    i4 += i5;
                }
            }
            iArr2[i3] = iArr2[i3] + i4;
        }
        int i6 = 8;
        for (int i7 = 0; i7 < N.length; i7++) {
            if (!this.g0[i7].isEmpty()) {
                iArr[i7] = i6;
                i6 = (this.g0[i7].size() * 12) + 2 + 4 + iArr2[i7] + i6;
            }
        }
        if (this.j0) {
            this.g0[4].put(P.f2763b, d.b(i6, this.i0));
            this.l0 = i6;
            i6 += this.m0;
        }
        if (this.e0 == 4) {
            i6 += 8;
        }
        if (a) {
            for (int i8 = 0; i8 < N.length; i8++) {
                Log.d("ExifInterface", String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d", Integer.valueOf(i8), Integer.valueOf(iArr[i8]), Integer.valueOf(this.g0[i8].size()), Integer.valueOf(iArr2[i8]), Integer.valueOf(i6)));
            }
        }
        if (!this.g0[1].isEmpty()) {
            this.g0[0].put(O[1].f2763b, d.b(iArr[1], this.i0));
        }
        if (!this.g0[2].isEmpty()) {
            this.g0[0].put(O[2].f2763b, d.b(iArr[2], this.i0));
        }
        if (!this.g0[3].isEmpty()) {
            this.g0[1].put(O[3].f2763b, d.b(iArr[3], this.i0));
        }
        int i9 = this.e0;
        if (i9 == 4) {
            cVar.b((short) i6);
            cVar.f2758d.write(W);
        } else if (i9 == 13) {
            cVar.a(i6);
            cVar.f2758d.write(f2752m);
        } else if (i9 == 14) {
            cVar.f2758d.write(r);
            cVar.a(i6);
        }
        cVar.b(this.i0 == ByteOrder.BIG_ENDIAN ? (short) 19789 : (short) 18761);
        cVar.f2759h = this.i0;
        cVar.b((short) 42);
        cVar.a((int) 8);
        for (int i10 = 0; i10 < N.length; i10++) {
            if (!this.g0[i10].isEmpty()) {
                cVar.b((short) this.g0[i10].size());
                int size = (this.g0[i10].size() * 12) + iArr[i10] + 2 + 4;
                for (Map.Entry<String, d> entry3 : this.g0[i10].entrySet()) {
                    int i11 = S[i10].get(entry3.getKey()).a;
                    d value2 = entry3.getValue();
                    Objects.requireNonNull(value2);
                    int i12 = B[value2.a] * value2.f2760b;
                    cVar.b((short) i11);
                    cVar.b((short) value2.a);
                    cVar.a(value2.f2760b);
                    if (i12 > 4) {
                        cVar.a(size);
                        size += i12;
                    } else {
                        cVar.f2758d.write(value2.f2762d);
                        if (i12 < 4) {
                            while (i12 < 4) {
                                cVar.f2758d.write(0);
                                i12++;
                            }
                        }
                    }
                }
                if (i10 == 0 && !this.g0[4].isEmpty()) {
                    cVar.a(iArr[4]);
                } else {
                    cVar.a((int) 0);
                }
                for (Map.Entry<String, d> entry4 : this.g0[i10].entrySet()) {
                    byte[] bArr = entry4.getValue().f2762d;
                    if (bArr.length > 4) {
                        cVar.f2758d.write(bArr, 0, bArr.length);
                    }
                }
            }
        }
        if (this.j0) {
            cVar.f2758d.write(x());
        }
        if (this.e0 == 14 && i6 % 2 == 1) {
            cVar.f2758d.write(0);
        }
        cVar.f2759h = ByteOrder.BIG_ENDIAN;
        return i6;
    }

    public final void a() {
        String k2 = k("DateTimeOriginal");
        if (k2 != null && k("DateTime") == null) {
            this.g0[0].put("DateTime", d.a(k2));
        }
        if (k("ImageWidth") == null) {
            this.g0[0].put("ImageWidth", d.b(0L, this.i0));
        }
        if (k("ImageLength") == null) {
            this.g0[0].put("ImageLength", d.b(0L, this.i0));
        }
        if (k("Orientation") == null) {
            this.g0[0].put("Orientation", d.b(0L, this.i0));
        }
        if (k("LightSource") == null) {
            this.g0[1].put("LightSource", d.b(0L, this.i0));
        }
    }

    public final void i(b bVar, c cVar, byte[] bArr, byte[] bArr2) {
        String sb;
        while (true) {
            byte[] bArr3 = new byte[4];
            if (bVar.read(bArr3) != 4) {
                StringBuilder O2 = e.a.a.a.a.O("Encountered invalid length while copying WebP chunks up tochunk type ");
                Charset charset = V;
                O2.append(new String(bArr, charset));
                if (bArr2 == null) {
                    sb = "";
                } else {
                    StringBuilder O3 = e.a.a.a.a.O(" or ");
                    O3.append(new String(bArr2, charset));
                    sb = O3.toString();
                }
                O2.append(sb);
                throw new IOException(O2.toString());
            }
            j(bVar, cVar, bArr3);
            if (Arrays.equals(bArr3, bArr)) {
                return;
            }
            if (bArr2 != null && Arrays.equals(bArr3, bArr2)) {
                return;
            }
        }
    }

    public final void j(b bVar, c cVar, byte[] bArr) {
        int readInt = bVar.readInt();
        cVar.f2758d.write(bArr);
        cVar.a(readInt);
        if (readInt % 2 == 1) {
            readInt++;
        }
        h(bVar, cVar, readInt);
    }

    public String k(String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        d n2 = n(str);
        if (n2 != null) {
            if (!T.contains(str)) {
                return n2.i(this.i0);
            }
            if (str.equals("GPSTimeStamp")) {
                int i2 = n2.a;
                if (i2 != 5 && i2 != 10) {
                    StringBuilder O2 = e.a.a.a.a.O("GPS Timestamp format is not rational. format=");
                    O2.append(n2.a);
                    Log.w("ExifInterface", O2.toString());
                    return null;
                }
                f[] fVarArr = (f[]) n2.j(this.i0);
                if (fVarArr != null && fVarArr.length == 3) {
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) fVarArr[0].a) / ((float) fVarArr[0].f2766b))), Integer.valueOf((int) (((float) fVarArr[1].a) / ((float) fVarArr[1].f2766b))), Integer.valueOf((int) (((float) fVarArr[2].a) / ((float) fVarArr[2].f2766b))));
                }
                StringBuilder O3 = e.a.a.a.a.O("Invalid GPS Timestamp array. array=");
                O3.append(Arrays.toString(fVarArr));
                Log.w("ExifInterface", O3.toString());
                return null;
            }
            try {
                return Double.toString(n2.g(this.i0));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public double l(String str, double d2) {
        d n2 = n(str);
        if (n2 == null) {
            return d2;
        }
        try {
            return n2.g(this.i0);
        } catch (NumberFormatException unused) {
            return d2;
        }
    }

    public int m(String str, int i2) {
        d n2 = n(str);
        if (n2 == null) {
            return i2;
        }
        try {
            return n2.h(this.i0);
        } catch (NumberFormatException unused) {
            return i2;
        }
    }

    public final d n(String str) {
        if ("ISOSpeedRatings".equals(str)) {
            if (a) {
                Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str = "PhotographicSensitivity";
        }
        for (int i2 = 0; i2 < N.length; i2++) {
            d dVar = this.g0[i2].get(str);
            if (dVar != null) {
                return dVar;
            }
        }
        return null;
    }

    public final void o(b bVar) {
        String str;
        String str2;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new C0028a(this, bVar));
            } else {
                FileDescriptor fileDescriptor = this.c0;
                if (fileDescriptor != null) {
                    mediaMetadataRetriever.setDataSource(fileDescriptor);
                } else {
                    String str3 = this.b0;
                    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.g0[0].put("ImageWidth", d.e(Integer.parseInt(str4), this.i0));
            }
            if (str != null) {
                this.g0[0].put("ImageLength", d.e(Integer.parseInt(str), this.i0));
            }
            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.g0[0].put("Orientation", d.e(i2, this.i0));
            }
            if (extractMetadata != null && extractMetadata2 != null) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 > 6) {
                    bVar.b(parseInt2);
                    byte[] bArr = new byte[6];
                    if (bVar.read(bArr) == 6) {
                        int i3 = parseInt2 + 6;
                        int i4 = parseInt3 - 6;
                        if (Arrays.equals(bArr, W)) {
                            byte[] bArr2 = new byte[i4];
                            if (bVar.read(bArr2) == i4) {
                                this.p0 = i3;
                                H(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");
                }
            }
            if (a) {
                Log.d("ExifInterface", "Heif meta: " + str4 + "x" + str + ", rotation " + str2);
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void p(b bVar, int i2, int i3) {
        if (a) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        char c2 = 0;
        bVar.mark(0);
        bVar.n = ByteOrder.BIG_ENDIAN;
        byte readByte = bVar.readByte();
        byte b2 = -1;
        if (readByte == -1) {
            if (bVar.readByte() != -40) {
                StringBuilder O2 = e.a.a.a.a.O("Invalid marker: ");
                O2.append(Integer.toHexString(readByte & 255));
                throw new IOException(O2.toString());
            }
            int i4 = 2;
            int i5 = 2;
            while (true) {
                byte readByte2 = bVar.readByte();
                if (readByte2 == b2) {
                    int i6 = i5 + 1;
                    byte readByte3 = bVar.readByte();
                    boolean z2 = a;
                    if (z2) {
                        StringBuilder O3 = e.a.a.a.a.O("Found JPEG segment indicator: ");
                        O3.append(Integer.toHexString(readByte3 & 255));
                        Log.d("ExifInterface", O3.toString());
                    }
                    int i7 = i6 + 1;
                    if (readByte3 != -39 && readByte3 != -38) {
                        int readUnsignedShort = bVar.readUnsignedShort() - i4;
                        int i8 = i7 + i4;
                        if (z2) {
                            StringBuilder O4 = e.a.a.a.a.O("JPEG segment: ");
                            O4.append(Integer.toHexString(readByte3 & 255));
                            O4.append(" (length: ");
                            O4.append(readUnsignedShort + 2);
                            O4.append(")");
                            Log.d("ExifInterface", O4.toString());
                        }
                        if (readUnsignedShort < 0) {
                            throw new IOException("Invalid length");
                        }
                        if (readByte3 == -31) {
                            byte[] bArr = new byte[readUnsignedShort];
                            bVar.readFully(bArr);
                            int i9 = i8 + readUnsignedShort;
                            byte[] bArr2 = W;
                            if (Q(bArr, bArr2)) {
                                byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                                this.p0 = i2 + i8 + bArr2.length;
                                H(copyOfRange, i3);
                                P(new b(copyOfRange));
                            } else {
                                byte[] bArr3 = X;
                                if (Q(bArr, bArr3)) {
                                    int length = i8 + bArr3.length;
                                    byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                                    if (k("Xmp") == null) {
                                        this.g0[c2].put("Xmp", new d(1, copyOfRange2.length, length, copyOfRange2));
                                        this.t0 = true;
                                    }
                                }
                            }
                            i8 = i9;
                        } 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.g0[i3].put("ImageLength", d.b(bVar.readUnsignedShort(), this.i0));
                                                        this.g0[i3].put("ImageWidth", d.b(bVar.readUnsignedShort(), this.i0));
                                                        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");
                                }
                                i5 = i8 + readUnsignedShort;
                                c2 = 0;
                                i4 = 2;
                                b2 = -1;
                            } else {
                                throw new IOException("Invalid length");
                            }
                        } else {
                            byte[] bArr4 = new byte[readUnsignedShort];
                            if (bVar.read(bArr4) == readUnsignedShort) {
                                if (k("UserComment") == null) {
                                    this.g0[1].put("UserComment", d.a(new String(bArr4, V)));
                                }
                            } else {
                                throw new IOException("Invalid exif");
                            }
                        }
                        readUnsignedShort = 0;
                        if (readUnsignedShort < 0) {
                        }
                    }
                } else {
                    StringBuilder O5 = e.a.a.a.a.O("Invalid marker:");
                    O5.append(Integer.toHexString(readByte2 & 255));
                    throw new IOException(O5.toString());
                }
            }
        } else {
            StringBuilder O6 = e.a.a.a.a.O("Invalid marker: ");
            O6.append(Integer.toHexString(readByte & 255));
            throw new IOException(O6.toString());
        }
    }

    public final int q(BufferedInputStream bufferedInputStream) {
        boolean z2;
        boolean z3;
        b bVar;
        b bVar2;
        boolean z4;
        b bVar3;
        b bVar4;
        boolean z5;
        b bVar5;
        b bVar6;
        boolean z6;
        boolean z7;
        boolean z8;
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i2 = 0;
        while (true) {
            byte[] bArr2 = f2745f;
            if (i2 >= bArr2.length) {
                z2 = true;
                break;
            } else if (bArr[i2] != bArr2[i2]) {
                z2 = false;
                break;
            } else {
                i2++;
            }
        }
        if (z2) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i3 = 0;
        while (true) {
            if (i3 >= bytes.length) {
                z3 = true;
                break;
            } else if (bArr[i3] != bytes[i3]) {
                z3 = false;
                break;
            } else {
                i3++;
            }
        }
        if (z3) {
            return 9;
        }
        try {
            bVar2 = new b(bArr);
            try {
                long readInt = bVar2.readInt();
                byte[] bArr3 = new byte[4];
                bVar2.read(bArr3);
                if (Arrays.equals(bArr3, f2746g)) {
                    long j2 = 16;
                    if (readInt == 1) {
                        readInt = bVar2.readLong();
                        if (readInt < 16) {
                        }
                    } else {
                        j2 = 8;
                    }
                    long j3 = 5000;
                    if (readInt > j3) {
                        readInt = j3;
                    }
                    long j4 = readInt - j2;
                    if (j4 >= 8) {
                        byte[] bArr4 = new byte[4];
                        boolean z9 = false;
                        boolean z10 = false;
                        for (long j5 = 0; j5 < j4 / 4 && bVar2.read(bArr4) == 4; j5++) {
                            if (j5 != 1) {
                                if (Arrays.equals(bArr4, f2747h)) {
                                    z9 = true;
                                } else if (Arrays.equals(bArr4, f2748i)) {
                                    z10 = true;
                                }
                                if (z9 && z10) {
                                    bVar2.close();
                                    z4 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e2) {
                e = e2;
                try {
                    if (a) {
                        Log.d("ExifInterface", "Exception parsing HEIF file type box.", e);
                    }
                } catch (Throwable th) {
                    th = th;
                    bVar = bVar2;
                    bVar2 = bVar;
                    if (bVar2 != null) {
                        bVar2.close();
                    }
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
                if (bVar2 != null) {
                }
                throw th;
            }
        } catch (Exception e3) {
            e = e3;
            bVar2 = null;
        } catch (Throwable th3) {
            th = th3;
            bVar = null;
            bVar2 = bVar;
            if (bVar2 != null) {
            }
            throw th;
        }
        bVar2.close();
        z4 = false;
        if (z4) {
            return 12;
        }
        try {
            bVar4 = new b(bArr);
            try {
                ByteOrder G2 = G(bVar4);
                this.i0 = G2;
                bVar4.n = G2;
                short readShort = bVar4.readShort();
                z5 = readShort == 20306 || readShort == 21330;
                bVar4.close();
            } catch (Exception unused) {
                if (bVar4 != null) {
                    bVar4.close();
                }
                z5 = false;
                if (z5) {
                }
            } catch (Throwable th4) {
                th = th4;
                bVar3 = bVar4;
                if (bVar3 != null) {
                    bVar3.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
            bVar4 = null;
        } catch (Throwable th5) {
            th = th5;
            bVar3 = null;
        }
        if (z5) {
            try {
                b bVar7 = new b(bArr);
                try {
                    ByteOrder G3 = G(bVar7);
                    this.i0 = G3;
                    bVar7.n = G3;
                    z6 = bVar7.readShort() == 85;
                    bVar7.close();
                } catch (Exception unused3) {
                    bVar6 = bVar7;
                    if (bVar6 != null) {
                        bVar6.close();
                    }
                    z6 = false;
                    if (z6) {
                    }
                } catch (Throwable th6) {
                    th = th6;
                    bVar5 = bVar7;
                    if (bVar5 != null) {
                        bVar5.close();
                    }
                    throw th;
                }
            } catch (Exception unused4) {
                bVar6 = null;
            } catch (Throwable th7) {
                th = th7;
                bVar5 = null;
            }
            if (z6) {
                int i4 = 0;
                while (true) {
                    byte[] bArr5 = f2751l;
                    if (i4 >= bArr5.length) {
                        z7 = true;
                        break;
                    } else if (bArr[i4] != bArr5[i4]) {
                        z7 = false;
                        break;
                    } else {
                        i4++;
                    }
                }
                if (z7) {
                    return 13;
                }
                int i5 = 0;
                while (true) {
                    byte[] bArr6 = p;
                    if (i5 >= bArr6.length) {
                        int i6 = 0;
                        while (true) {
                            byte[] bArr7 = q;
                            if (i6 >= bArr7.length) {
                                z8 = true;
                                break;
                            } else if (bArr[p.length + i6 + 4] != bArr7[i6]) {
                                break;
                            } else {
                                i6++;
                            }
                        }
                    } else if (bArr[i5] != bArr6[i5]) {
                        break;
                    } else {
                        i5++;
                    }
                }
                z8 = false;
                return z8 ? 14 : 0;
            }
            return 10;
        }
        return 7;
    }

    public final void r(b bVar) {
        u(bVar);
        d dVar = this.g0[1].get("MakerNote");
        if (dVar != null) {
            b bVar2 = new b(dVar.f2762d);
            bVar2.n = this.i0;
            byte[] bArr = f2749j;
            byte[] bArr2 = new byte[bArr.length];
            bVar2.readFully(bArr2);
            bVar2.b(0L);
            byte[] bArr3 = f2750k;
            byte[] bArr4 = new byte[bArr3.length];
            bVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                bVar2.b(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                bVar2.b(12L);
            }
            I(bVar2, 6);
            d dVar2 = this.g0[7].get("PreviewImageStart");
            d dVar3 = this.g0[7].get("PreviewImageLength");
            if (dVar2 != null && dVar3 != null) {
                this.g0[5].put("JPEGInterchangeFormat", dVar2);
                this.g0[5].put("JPEGInterchangeFormatLength", dVar3);
            }
            d dVar4 = this.g0[8].get("AspectFrame");
            if (dVar4 != null) {
                int[] iArr = (int[]) dVar4.j(this.i0);
                if (iArr != null && iArr.length == 4) {
                    if (iArr[2] <= iArr[0] || iArr[3] <= iArr[1]) {
                        return;
                    }
                    int i2 = (iArr[2] - iArr[0]) + 1;
                    int i3 = (iArr[3] - iArr[1]) + 1;
                    if (i2 < i3) {
                        int i4 = i2 + i3;
                        i3 = i4 - i3;
                        i2 = i4 - i3;
                    }
                    d e2 = d.e(i2, this.i0);
                    d e3 = d.e(i3, this.i0);
                    this.g0[0].put("ImageWidth", e2);
                    this.g0[0].put("ImageLength", e3);
                    return;
                }
                StringBuilder O2 = e.a.a.a.a.O("Invalid aspect frame values. frame=");
                O2.append(Arrays.toString(iArr));
                Log.w("ExifInterface", O2.toString());
            }
        }
    }

    public final void s(b bVar) {
        if (a) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.mark(0);
        bVar.n = ByteOrder.BIG_ENDIAN;
        byte[] bArr = f2751l;
        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 i3 = i2 + 4;
                    if (i3 == 16 && !Arrays.equals(bArr2, n)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (Arrays.equals(bArr2, o)) {
                        return;
                    }
                    if (Arrays.equals(bArr2, f2752m)) {
                        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.p0 = i3;
                                H(bArr3, 0);
                                T();
                                P(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 i4 = readInt + 4;
                    bVar.skipBytes(i4);
                    length = i3 + i4;
                } else {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void t(b bVar) {
        boolean z2 = a;
        if (z2) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + 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 i3 = ByteBuffer.wrap(bArr2).getInt();
        int i4 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i3];
        bVar.b(i2);
        bVar.read(bArr4);
        p(new b(bArr4), i2, 5);
        bVar.b(i4);
        bVar.n = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (z2) {
            e.a.a.a.a.p0("numberOfDirectoryEntry: ", readInt, "ExifInterface");
        }
        for (int i5 = 0; i5 < readInt; i5++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == I.a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                d e2 = d.e(readShort, this.i0);
                d e3 = d.e(readShort2, this.i0);
                this.g0[0].put("ImageLength", e2);
                this.g0[0].put("ImageWidth", e3);
                if (a) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    public final void u(b bVar) {
        d dVar;
        E(bVar, bVar.available());
        I(bVar, 0);
        S(bVar, 0);
        S(bVar, 5);
        S(bVar, 4);
        T();
        if (this.e0 != 8 || (dVar = this.g0[1].get("MakerNote")) == null) {
            return;
        }
        b bVar2 = new b(dVar.f2762d);
        bVar2.n = this.i0;
        bVar2.b(6L);
        I(bVar2, 9);
        d dVar2 = this.g0[9].get("ColorSpace");
        if (dVar2 != null) {
            this.g0[1].put("ColorSpace", dVar2);
        }
    }

    public final void v(b bVar) {
        if (a) {
            Log.d("ExifInterface", "getRw2Attributes starting with: " + bVar);
        }
        u(bVar);
        d dVar = this.g0[0].get("JpgFromRaw");
        if (dVar != null) {
            p(new b(dVar.f2762d), (int) dVar.f2761c, 5);
        }
        d dVar2 = this.g0[0].get("ISO");
        d dVar3 = this.g0[1].get("PhotographicSensitivity");
        if (dVar2 == null || dVar3 != null) {
            return;
        }
        this.g0[1].put("PhotographicSensitivity", dVar2);
    }

    public final void w(b bVar) {
        byte[] bArr = W;
        bVar.skipBytes(bArr.length);
        byte[] bArr2 = new byte[bVar.available()];
        bVar.readFully(bArr2);
        this.p0 = bArr.length;
        H(bArr2, 0);
    }

    public byte[] x() {
        FileDescriptor fileDescriptor;
        FileInputStream fileInputStream;
        Exception e2;
        FileDescriptor fileDescriptor2;
        FileInputStream fileInputStream2;
        FileInputStream fileInputStream3;
        Closeable closeable = null;
        if (!this.j0) {
            return null;
        }
        ?? r1 = this.n0;
        try {
            if (r1 != 0) {
                return r1;
            }
            try {
                r1 = this.d0;
                try {
                    if (r1 != 0) {
                        try {
                            if (r1.markSupported()) {
                                r1.reset();
                                fileInputStream3 = r1;
                            } else {
                                Log.d("ExifInterface", "Cannot read thumbnail from inputstream without mark/reset support");
                                d(r1);
                                return null;
                            }
                        } catch (Exception e3) {
                            e2 = e3;
                            fileDescriptor2 = null;
                            fileInputStream = r1;
                            Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2);
                            d(fileInputStream);
                            if (fileDescriptor2 != null) {
                            }
                            return null;
                        } catch (Throwable th) {
                            th = th;
                            fileDescriptor = null;
                            closeable = r1;
                            d(closeable);
                            if (fileDescriptor != null) {
                            }
                            throw th;
                        }
                    } else if (this.b0 != null) {
                        fileInputStream3 = new FileInputStream(this.b0);
                    } else {
                        FileDescriptor dup = Os.dup(this.c0);
                        try {
                            Os.lseek(dup, 0L, OsConstants.SEEK_SET);
                            fileDescriptor2 = dup;
                            fileInputStream2 = new FileInputStream(dup);
                            if (fileInputStream2 == null) {
                                if (fileInputStream2.skip(this.l0 + this.p0) == this.l0 + this.p0) {
                                    byte[] bArr = new byte[this.m0];
                                    if (fileInputStream2.read(bArr) == this.m0) {
                                        this.n0 = bArr;
                                        d(fileInputStream2);
                                        if (fileDescriptor2 != null) {
                                            c(fileDescriptor2);
                                        }
                                        return bArr;
                                    }
                                    throw new IOException("Corrupted image");
                                }
                                throw new IOException("Corrupted image");
                            }
                            throw new FileNotFoundException();
                        } catch (Exception e4) {
                            e2 = e4;
                            fileDescriptor2 = dup;
                            fileInputStream = null;
                            Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2);
                            d(fileInputStream);
                            if (fileDescriptor2 != null) {
                            }
                            return null;
                        } catch (Throwable th2) {
                            th = th2;
                            fileDescriptor = dup;
                            d(closeable);
                            if (fileDescriptor != null) {
                                c(fileDescriptor);
                            }
                            throw th;
                        }
                    }
                    if (fileInputStream2 == null) {
                    }
                } catch (Exception e5) {
                    e2 = e5;
                    fileInputStream = fileInputStream2;
                    Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2);
                    d(fileInputStream);
                    if (fileDescriptor2 != null) {
                        c(fileDescriptor2);
                    }
                    return null;
                }
                fileDescriptor2 = null;
                fileInputStream2 = fileInputStream3;
            } catch (Exception e6) {
                fileInputStream = null;
                e2 = e6;
                fileDescriptor2 = null;
            } catch (Throwable th3) {
                th = th3;
                fileDescriptor = null;
            }
        } catch (Throwable th4) {
            th = th4;
        }
    }

    public final void y(b bVar) {
        if (a) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.mark(0);
        bVar.n = ByteOrder.LITTLE_ENDIAN;
        bVar.skipBytes(p.length);
        int readInt = bVar.readInt() + 8;
        int skipBytes = bVar.skipBytes(q.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(r, bArr)) {
                        byte[] bArr2 = new byte[readInt2];
                        if (bVar.read(bArr2) == readInt2) {
                            this.p0 = i2;
                            H(bArr2, 0);
                            P(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 i3 = i2 + readInt2;
                    if (i3 == readInt) {
                        return;
                    }
                    if (i3 <= 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 static class b extends InputStream implements DataInput {
        public static final ByteOrder f2755d = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder f2756h = ByteOrder.BIG_ENDIAN;
        public DataInputStream f2757m;
        public ByteOrder n;
        public final int o;
        public int p;

        public b(InputStream inputStream, ByteOrder byteOrder) {
            this.n = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f2757m = dataInputStream;
            int available = dataInputStream.available();
            this.o = available;
            this.p = 0;
            this.f2757m.mark(available);
            this.n = byteOrder;
        }

        public long a() {
            return readInt() & 4294967295L;
        }

        @Override
        public int available() {
            return this.f2757m.available();
        }

        public void b(long j2) {
            int i2 = this.p;
            if (i2 > j2) {
                this.p = 0;
                this.f2757m.reset();
                this.f2757m.mark(this.o);
            } else {
                j2 -= i2;
            }
            int i3 = (int) j2;
            if (skipBytes(i3) != i3) {
                throw new IOException("Couldn't seek up to the byteCount");
            }
        }

        @Override
        public synchronized void mark(int i2) {
            this.f2757m.mark(i2);
        }

        @Override
        public int read() {
            this.p++;
            return this.f2757m.read();
        }

        @Override
        public boolean readBoolean() {
            this.p++;
            return this.f2757m.readBoolean();
        }

        @Override
        public byte readByte() {
            int i2 = this.p + 1;
            this.p = i2;
            if (i2 <= this.o) {
                int read = this.f2757m.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public char readChar() {
            this.p += 2;
            return this.f2757m.readChar();
        }

        @Override
        public double readDouble() {
            return Double.longBitsToDouble(readLong());
        }

        @Override
        public float readFloat() {
            return Float.intBitsToFloat(readInt());
        }

        @Override
        public void readFully(byte[] bArr, int i2, int i3) {
            int i4 = this.p + i3;
            this.p = i4;
            if (i4 <= this.o) {
                if (this.f2757m.read(bArr, i2, i3) != i3) {
                    throw new IOException("Couldn't read up to the length of buffer");
                }
                return;
            }
            throw new EOFException();
        }

        @Override
        public int readInt() {
            int i2 = this.p + 4;
            this.p = i2;
            if (i2 <= this.o) {
                int read = this.f2757m.read();
                int read2 = this.f2757m.read();
                int read3 = this.f2757m.read();
                int read4 = this.f2757m.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.n;
                    if (byteOrder == f2755d) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f2756h) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    StringBuilder O = e.a.a.a.a.O("Invalid byte order: ");
                    O.append(this.n);
                    throw new IOException(O.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public String readLine() {
            Log.d("ExifInterface", "Currently unsupported");
            return null;
        }

        @Override
        public long readLong() {
            int i2 = this.p + 8;
            this.p = i2;
            if (i2 <= this.o) {
                int read = this.f2757m.read();
                int read2 = this.f2757m.read();
                int read3 = this.f2757m.read();
                int read4 = this.f2757m.read();
                int read5 = this.f2757m.read();
                int read6 = this.f2757m.read();
                int read7 = this.f2757m.read();
                int read8 = this.f2757m.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.n;
                    if (byteOrder == f2755d) {
                        return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f2756h) {
                        return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                    }
                    StringBuilder O = e.a.a.a.a.O("Invalid byte order: ");
                    O.append(this.n);
                    throw new IOException(O.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public short readShort() {
            int i2 = this.p + 2;
            this.p = i2;
            if (i2 <= this.o) {
                int read = this.f2757m.read();
                int read2 = this.f2757m.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.n;
                    if (byteOrder == f2755d) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == f2756h) {
                        return (short) ((read << 8) + read2);
                    }
                    StringBuilder O = e.a.a.a.a.O("Invalid byte order: ");
                    O.append(this.n);
                    throw new IOException(O.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public String readUTF() {
            this.p += 2;
            return this.f2757m.readUTF();
        }

        @Override
        public int readUnsignedByte() {
            this.p++;
            return this.f2757m.readUnsignedByte();
        }

        @Override
        public int readUnsignedShort() {
            int i2 = this.p + 2;
            this.p = i2;
            if (i2 <= this.o) {
                int read = this.f2757m.read();
                int read2 = this.f2757m.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.n;
                    if (byteOrder == f2755d) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == f2756h) {
                        return (read << 8) + read2;
                    }
                    StringBuilder O = e.a.a.a.a.O("Invalid byte order: ");
                    O.append(this.n);
                    throw new IOException(O.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public int skipBytes(int i2) {
            int min = Math.min(i2, this.o - this.p);
            int i3 = 0;
            while (i3 < min) {
                i3 += this.f2757m.skipBytes(min - i3);
            }
            this.p += i3;
            return i3;
        }

        @Override
        public int read(byte[] bArr, int i2, int i3) {
            int read = this.f2757m.read(bArr, i2, i3);
            this.p += read;
            return read;
        }

        @Override
        public void readFully(byte[] bArr) {
            int length = this.p + bArr.length;
            this.p = length;
            if (length <= this.o) {
                if (this.f2757m.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 d {
        public final int a;
        public final int f2760b;
        public final long f2761c;
        public final byte[] f2762d;

        public d(int i2, int i3, long j2, byte[] bArr) {
            this.a = i2;
            this.f2760b = i3;
            this.f2761c = j2;
            this.f2762d = bArr;
        }

        public static d a(String str) {
            byte[] bytes = (str + (char) 0).getBytes(a.V);
            return new d(2, bytes.length, bytes);
        }

        public static d b(long j2, ByteOrder byteOrder) {
            return c(new long[]{j2}, byteOrder);
        }

        public static d c(long[] jArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.B[4] * jArr.length]);
            wrap.order(byteOrder);
            for (long j2 : jArr) {
                wrap.putInt((int) j2);
            }
            return new d(4, jArr.length, wrap.array());
        }

        public static d d(f[] fVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.B[5] * fVarArr.length]);
            wrap.order(byteOrder);
            for (f fVar : fVarArr) {
                wrap.putInt((int) fVar.a);
                wrap.putInt((int) fVar.f2766b);
            }
            return new d(5, fVarArr.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.B[3] * iArr.length]);
            wrap.order(byteOrder);
            for (int i2 : iArr) {
                wrap.putShort((short) i2);
            }
            return new d(3, iArr.length, wrap.array());
        }

        public double g(ByteOrder byteOrder) {
            Object j2 = j(byteOrder);
            if (j2 != null) {
                if (j2 instanceof String) {
                    return Double.parseDouble((String) j2);
                }
                if (j2 instanceof long[]) {
                    long[] jArr = (long[]) j2;
                    if (jArr.length == 1) {
                        return jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j2 instanceof int[]) {
                    int[] iArr = (int[]) j2;
                    if (iArr.length == 1) {
                        return iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j2 instanceof double[]) {
                    double[] dArr = (double[]) j2;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j2 instanceof f[]) {
                    f[] fVarArr = (f[]) j2;
                    if (fVarArr.length == 1) {
                        f fVar = fVarArr[0];
                        return fVar.a / fVar.f2766b;
                    }
                    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 int h(ByteOrder byteOrder) {
            Object j2 = j(byteOrder);
            if (j2 != null) {
                if (j2 instanceof String) {
                    return Integer.parseInt((String) j2);
                }
                if (j2 instanceof long[]) {
                    long[] jArr = (long[]) j2;
                    if (jArr.length == 1) {
                        return (int) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j2 instanceof int[]) {
                    int[] iArr = (int[]) j2;
                    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 String i(ByteOrder byteOrder) {
            Object j2 = j(byteOrder);
            if (j2 == null) {
                return null;
            }
            if (j2 instanceof String) {
                return (String) j2;
            }
            StringBuilder sb = new StringBuilder();
            int i2 = 0;
            if (j2 instanceof long[]) {
                long[] jArr = (long[]) j2;
                while (i2 < jArr.length) {
                    sb.append(jArr[i2]);
                    i2++;
                    if (i2 != jArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (j2 instanceof int[]) {
                int[] iArr = (int[]) j2;
                while (i2 < iArr.length) {
                    sb.append(iArr[i2]);
                    i2++;
                    if (i2 != iArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (j2 instanceof double[]) {
                double[] dArr = (double[]) j2;
                while (i2 < dArr.length) {
                    sb.append(dArr[i2]);
                    i2++;
                    if (i2 != dArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (j2 instanceof f[]) {
                f[] fVarArr = (f[]) j2;
                while (i2 < fVarArr.length) {
                    sb.append(fVarArr[i2].a);
                    sb.append('/');
                    sb.append(fVarArr[i2].f2766b);
                    i2++;
                    if (i2 != fVarArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else {
                return null;
            }
        }

        public Object j(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b2;
            byte[] bArr;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(this.f2762d);
                    try {
                        bVar.n = byteOrder;
                        boolean z = true;
                        int i2 = 0;
                        switch (this.a) {
                            case 1:
                            case 6:
                                byte[] bArr2 = this.f2762d;
                                if (bArr2.length == 1 && bArr2[0] >= 0 && bArr2[0] <= 1) {
                                    String str = new String(new char[]{(char) (this.f2762d[0] + 48)});
                                    try {
                                        bVar.close();
                                    } catch (IOException e2) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e2);
                                    }
                                    return str;
                                }
                                String str2 = new String(this.f2762d, a.V);
                                try {
                                    bVar.close();
                                } catch (IOException e3) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e3);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (this.f2760b >= a.C.length) {
                                    int i3 = 0;
                                    while (true) {
                                        bArr = a.C;
                                        if (i3 < bArr.length) {
                                            if (this.f2762d[i3] != bArr[i3]) {
                                                z = false;
                                            } else {
                                                i3++;
                                            }
                                        }
                                    }
                                    if (z) {
                                        i2 = bArr.length;
                                    }
                                }
                                StringBuilder sb = new StringBuilder();
                                while (i2 < this.f2760b && (b2 = this.f2762d[i2]) != 0) {
                                    if (b2 >= 32) {
                                        sb.append((char) b2);
                                    } else {
                                        sb.append('?');
                                    }
                                    i2++;
                                }
                                String sb2 = sb.toString();
                                try {
                                    bVar.close();
                                } catch (IOException e4) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e4);
                                }
                                return sb2;
                            case 3:
                                int[] iArr = new int[this.f2760b];
                                while (i2 < this.f2760b) {
                                    iArr[i2] = bVar.readUnsignedShort();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e5) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e5);
                                }
                                return iArr;
                            case 4:
                                long[] jArr = new long[this.f2760b];
                                while (i2 < this.f2760b) {
                                    jArr[i2] = bVar.a();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e6) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e6);
                                }
                                return jArr;
                            case 5:
                                f[] fVarArr = new f[this.f2760b];
                                while (i2 < this.f2760b) {
                                    fVarArr[i2] = new f(bVar.a(), bVar.a());
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e7) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e7);
                                }
                                return fVarArr;
                            case 8:
                                int[] iArr2 = new int[this.f2760b];
                                while (i2 < this.f2760b) {
                                    iArr2[i2] = bVar.readShort();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e8) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e8);
                                }
                                return iArr2;
                            case 9:
                                int[] iArr3 = new int[this.f2760b];
                                while (i2 < this.f2760b) {
                                    iArr3[i2] = bVar.readInt();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e9) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e9);
                                }
                                return iArr3;
                            case 10:
                                f[] fVarArr2 = new f[this.f2760b];
                                while (i2 < this.f2760b) {
                                    fVarArr2[i2] = new f(bVar.readInt(), bVar.readInt());
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e10) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                }
                                return fVarArr2;
                            case 11:
                                double[] dArr = new double[this.f2760b];
                                while (i2 < this.f2760b) {
                                    dArr[i2] = bVar.readFloat();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return dArr;
                            case 12:
                                double[] dArr2 = new double[this.f2760b];
                                while (i2 < this.f2760b) {
                                    dArr2[i2] = bVar.readDouble();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return dArr2;
                            default:
                                try {
                                    bVar.close();
                                } catch (IOException e13) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                                }
                                return null;
                        }
                    } catch (IOException e14) {
                        e = e14;
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (bVar != null) {
                            try {
                                bVar.close();
                            } catch (IOException e15) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th) {
                    th = th;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e16) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                        }
                    }
                    throw th;
                }
            } catch (IOException e17) {
                e = e17;
                bVar = null;
            } catch (Throwable th2) {
                th = th2;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

        public String toString() {
            StringBuilder O = e.a.a.a.a.O("(");
            O.append(a.A[this.a]);
            O.append(", data length:");
            return e.a.a.a.a.I(O, this.f2762d.length, ")");
        }

        public d(int i2, int i3, byte[] bArr) {
            this.a = i2;
            this.f2760b = i3;
            this.f2761c = -1L;
            this.f2762d = bArr;
        }
    }

    public static class e {
        public final int a;
        public final String f2763b;
        public final int f2764c;
        public final int f2765d;

        public e(String str, int i2, int i3) {
            this.f2763b = str;
            this.a = i2;
            this.f2764c = i3;
            this.f2765d = -1;
        }

        public e(String str, int i2, int i3, int i4) {
            this.f2763b = str;
            this.a = i2;
            this.f2764c = i3;
            this.f2765d = i4;
        }
    }

    public a(InputStream inputStream) {
        e[][] eVarArr = N;
        this.g0 = new HashMap[eVarArr.length];
        this.h0 = new HashSet(eVarArr.length);
        this.i0 = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(inputStream, "inputStream cannot be null");
        this.b0 = null;
        if (inputStream instanceof AssetManager.AssetInputStream) {
            this.d0 = (AssetManager.AssetInputStream) inputStream;
            this.c0 = null;
        } else {
            if (inputStream instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) inputStream;
                if (B(fileInputStream.getFD())) {
                    this.d0 = null;
                    this.c0 = fileInputStream.getFD();
                }
            }
            this.d0 = null;
            this.c0 = null;
        }
        D(inputStream);
    }
}