CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f

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


package e.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 java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
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.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
public class a {
    public static SimpleDateFormat I;
    public static final String[] J;
    public static final int[] K;
    public static final byte[] L;
    public static final d[] M;
    public static final d[] N;
    public static final d[] O;
    public static final d[] P;
    public static final d[] Q;
    public static final d R;
    public static final d[] S;
    public static final d[] T;
    public static final d[] U;
    public static final d[] V;
    public static final d[][] W;
    public static final d[] X;
    public static final HashMap<Integer, d>[] Y;
    public static final HashMap<String, d>[] Z;
    public static final HashSet<String> a0;
    public static final HashMap<Integer, Integer> b0;
    public static final Charset c0;
    public static final byte[] d0;
    public static final byte[] e0;
    public FileDescriptor a;
    public AssetManager.AssetInputStream b;
    public int c;
    public boolean f8753d;
    public final HashMap<String, c>[] f8754e;
    public Set<Integer> f8755f;
    public ByteOrder f8756g;
    public boolean f8757h;
    public int f8758i;
    public int f8759j;
    public int f8760k;
    public int f8761l;
    public int f8762m;
    public int f8763n;
    public int f8764o;
    public int f8765p;
    public static final boolean f8746q = Log.isLoggable("ExifInterface", 3);
    public static final List<Integer> f8747r = Arrays.asList(1, 6, 3, 8);
    public static final List<Integer> f8748s = Arrays.asList(2, 7, 4, 5);
    public static final int[] f8749t = {8, 8, 8};
    public static final int[] f8750u = {8};
    public static final byte[] f8751v = {-1, -40, -1};
    public static final byte[] f8752w = {102, 116, 121, 112};
    public static final byte[] x = {109, 105, 102, 49};
    public static final byte[] y = {104, 101, 105, 99};
    public static final byte[] z = {79, 76, 89, 77, 80, 0};
    public static final byte[] A = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] B = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] C = {101, 88, 73, 102};
    public static final byte[] D = {73, 72, 68, 82};
    public static final byte[] E = {73, 69, 78, 68};
    public static final byte[] F = {82, 73, 70, 70};
    public static final byte[] G = {87, 69, 66, 80};
    public static final byte[] H = {69, 88, 73, 70};

    public class C0067a extends MediaDataSource {
        public long f8766i;
        public final b f8767j;

        public C0067a(a aVar, b bVar) {
            this.f8767j = bVar;
        }

        @Override
        public void close() throws IOException {
        }

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

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

    public static class e {
        public final long a;
        public final long b;

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

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

    static {
        d[] dVarArr;
        "VP8X".getBytes(Charset.defaultCharset());
        "VP8L".getBytes(Charset.defaultCharset());
        "VP8 ".getBytes(Charset.defaultCharset());
        "ANIM".getBytes(Charset.defaultCharset());
        "ANMF".getBytes(Charset.defaultCharset());
        "XMP ".getBytes(Charset.defaultCharset());
        J = new String[]{"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
        K = new int[]{0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
        L = new byte[]{65, 83, 67, 73, 73, 0, 0, 0};
        d[] dVarArr2 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ImageWidth", 256, 3, 4), new d("ImageLength", 257, 3, 4), new d("BitsPerSample", 258, 3), new d("Compression", 259, 3), new d("PhotometricInterpretation", 262, 3), new d("ImageDescription", 270, 2), new d("Make", 271, 2), new d("Model", 272, 2), new d("StripOffsets", 273, 3, 4), new d("Orientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), new d("XResolution", 282, 5), new d("YResolution", 283, 5), new d("PlanarConfiguration", 284, 3), new d("ResolutionUnit", 296, 3), new d("TransferFunction", 301, 3), new d("Software", 305, 2), new d("DateTime", 306, 2), new d("Artist", 315, 2), new d("WhitePoint", 318, 5), new d("PrimaryChromaticities", 319, 5), new d("SubIFDPointer", 330, 4), new d("JPEGInterchangeFormat", 513, 4), new d("JPEGInterchangeFormatLength", 514, 4), new d("YCbCrCoefficients", 529, 5), new d("YCbCrSubSampling", 530, 3), new d("YCbCrPositioning", 531, 3), new d("ReferenceBlackWhite", 532, 5), new d("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("SensorTopBorder", 4, 4), new d("SensorLeftBorder", 5, 4), new d("SensorBottomBorder", 6, 4), new d("SensorRightBorder", 7, 4), new d("ISO", 23, 3), new d("JpgFromRaw", 46, 7), new d("Xmp", 700, 1)};
        M = dVarArr2;
        d[] dVarArr3 = {new d("ExposureTime", 33434, 5), new d("FNumber", 33437, 5), new d("ExposureProgram", 34850, 3), new d("SpectralSensitivity", 34852, 2), new d("PhotographicSensitivity", 34855, 3), new d("OECF", 34856, 7), new d("SensitivityType", 34864, 3), new d("StandardOutputSensitivity", 34865, 4), new d("RecommendedExposureIndex", 34866, 4), new d("ISOSpeed", 34867, 4), new d("ISOSpeedLatitudeyyy", 34868, 4), new d("ISOSpeedLatitudezzz", 34869, 4), new d("ExifVersion", 36864, 2), new d("DateTimeOriginal", 36867, 2), new d("DateTimeDigitized", 36868, 2), new d("OffsetTime", 36880, 2), new d("OffsetTimeOriginal", 36881, 2), new d("OffsetTimeDigitized", 36882, 2), new d("ComponentsConfiguration", 37121, 7), new d("CompressedBitsPerPixel", 37122, 5), new d("ShutterSpeedValue", 37377, 10), new d("ApertureValue", 37378, 5), new d("BrightnessValue", 37379, 10), new d("ExposureBiasValue", 37380, 10), new d("MaxApertureValue", 37381, 5), new d("SubjectDistance", 37382, 5), new d("MeteringMode", 37383, 3), new d("LightSource", 37384, 3), new d("Flash", 37385, 3), new d("FocalLength", 37386, 5), new d("SubjectArea", 37396, 3), new d("MakerNote", 37500, 7), new d("UserComment", 37510, 7), new d("SubSecTime", 37520, 2), new d("SubSecTimeOriginal", 37521, 2), new d("SubSecTimeDigitized", 37522, 2), new d("FlashpixVersion", 40960, 7), new d("ColorSpace", 40961, 3), new d("PixelXDimension", 40962, 3, 4), new d("PixelYDimension", 40963, 3, 4), new d("RelatedSoundFile", 40964, 2), new d("InteroperabilityIFDPointer", 40965, 4), new d("FlashEnergy", 41483, 5), new d("SpatialFrequencyResponse", 41484, 7), new d("FocalPlaneXResolution", 41486, 5), new d("FocalPlaneYResolution", 41487, 5), new d("FocalPlaneResolutionUnit", 41488, 3), new d("SubjectLocation", 41492, 3), new d("ExposureIndex", 41493, 5), new d("SensingMethod", 41495, 3), new d("FileSource", 41728, 7), new d("SceneType", 41729, 7), new d("CFAPattern", 41730, 7), new d("CustomRendered", 41985, 3), new d("ExposureMode", 41986, 3), new d("WhiteBalance", 41987, 3), new d("DigitalZoomRatio", 41988, 5), new d("FocalLengthIn35mmFilm", 41989, 3), new d("SceneCaptureType", 41990, 3), new d("GainControl", 41991, 3), new d("Contrast", 41992, 3), new d("Saturation", 41993, 3), new d("Sharpness", 41994, 3), new d("DeviceSettingDescription", 41995, 7), new d("SubjectDistanceRange", 41996, 3), new d("ImageUniqueID", 42016, 2), new d("CameraOwnerName", 42032, 2), new d("BodySerialNumber", 42033, 2), new d("LensSpecification", 42034, 5), new d("LensMake", 42035, 2), new d("LensModel", 42036, 2), new d("Gamma", 42240, 5), new d("DNGVersion", 50706, 1), new d("DefaultCropSize", 50720, 3, 4)};
        N = dVarArr3;
        d[] dVarArr4 = {new d("GPSVersionID", 0, 1), new d("GPSLatitudeRef", 1, 2), new d("GPSLatitude", 2, 5), new d("GPSLongitudeRef", 3, 2), new d("GPSLongitude", 4, 5), new d("GPSAltitudeRef", 5, 1), new d("GPSAltitude", 6, 5), new d("GPSTimeStamp", 7, 5), new d("GPSSatellites", 8, 2), new d("GPSStatus", 9, 2), new d("GPSMeasureMode", 10, 2), new d("GPSDOP", 11, 5), new d("GPSSpeedRef", 12, 2), new d("GPSSpeed", 13, 5), new d("GPSTrackRef", 14, 2), new d("GPSTrack", 15, 5), new d("GPSImgDirectionRef", 16, 2), new d("GPSImgDirection", 17, 5), new d("GPSMapDatum", 18, 2), new d("GPSDestLatitudeRef", 19, 2), new d("GPSDestLatitude", 20, 5), new d("GPSDestLongitudeRef", 21, 2), new d("GPSDestLongitude", 22, 5), new d("GPSDestBearingRef", 23, 2), new d("GPSDestBearing", 24, 5), new d("GPSDestDistanceRef", 25, 2), new d("GPSDestDistance", 26, 5), new d("GPSProcessingMethod", 27, 7), new d("GPSAreaInformation", 28, 7), new d("GPSDateStamp", 29, 2), new d("GPSDifferential", 30, 3), new d("GPSHPositioningError", 31, 5)};
        O = dVarArr4;
        d[] dVarArr5 = {new d("InteroperabilityIndex", 1, 2)};
        P = dVarArr5;
        d[] dVarArr6 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ThumbnailImageWidth", 256, 3, 4), new d("ThumbnailImageLength", 257, 3, 4), new d("BitsPerSample", 258, 3), new d("Compression", 259, 3), new d("PhotometricInterpretation", 262, 3), new d("ImageDescription", 270, 2), new d("Make", 271, 2), new d("Model", 272, 2), new d("StripOffsets", 273, 3, 4), new d("ThumbnailOrientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), new d("XResolution", 282, 5), new d("YResolution", 283, 5), new d("PlanarConfiguration", 284, 3), new d("ResolutionUnit", 296, 3), new d("TransferFunction", 301, 3), new d("Software", 305, 2), new d("DateTime", 306, 2), new d("Artist", 315, 2), new d("WhitePoint", 318, 5), new d("PrimaryChromaticities", 319, 5), new d("SubIFDPointer", 330, 4), new d("JPEGInterchangeFormat", 513, 4), new d("JPEGInterchangeFormatLength", 514, 4), new d("YCbCrCoefficients", 529, 5), new d("YCbCrSubSampling", 530, 3), new d("YCbCrPositioning", 531, 3), new d("ReferenceBlackWhite", 532, 5), new d("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("DNGVersion", 50706, 1), new d("DefaultCropSize", 50720, 3, 4)};
        Q = dVarArr6;
        R = new d("StripOffsets", 273, 3);
        d[] dVarArr7 = {new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)};
        S = dVarArr7;
        d[] dVarArr8 = {new d("PreviewImageStart", 257, 4), new d("PreviewImageLength", 258, 4)};
        T = dVarArr8;
        d[] dVarArr9 = {new d("AspectFrame", 4371, 3)};
        U = dVarArr9;
        d[] dVarArr10 = {new d("ColorSpace", 55, 3)};
        V = dVarArr10;
        d[][] dVarArr11 = {dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr6, dVarArr2, dVarArr7, dVarArr8, dVarArr9, dVarArr10};
        W = dVarArr11;
        X = new d[]{new d("SubIFDPointer", 330, 4), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("InteroperabilityIFDPointer", 40965, 4), new d("CameraSettingsIFDPointer", 8224, 1), new d("ImageProcessingIFDPointer", 8256, 1)};
        Y = new HashMap[dVarArr11.length];
        Z = new HashMap[dVarArr11.length];
        a0 = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        b0 = new HashMap<>();
        Charset forName = Charset.forName("US-ASCII");
        c0 = forName;
        d0 = "Exif\u0000\u0000".getBytes(forName);
        e0 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        I = simpleDateFormat;
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        int i2 = 0;
        while (true) {
            d[][] dVarArr12 = W;
            if (i2 < dVarArr12.length) {
                Y[i2] = new HashMap<>();
                Z[i2] = new HashMap<>();
                for (d dVar : dVarArr12[i2]) {
                    Y[i2].put(Integer.valueOf(dVar.a), dVar);
                    Z[i2].put(dVar.b, dVar);
                }
                i2++;
            } else {
                HashMap<Integer, Integer> hashMap = b0;
                d[] dVarArr13 = X;
                hashMap.put(Integer.valueOf(dVarArr13[0].a), 5);
                hashMap.put(Integer.valueOf(dVarArr13[1].a), 1);
                hashMap.put(Integer.valueOf(dVarArr13[2].a), 2);
                hashMap.put(Integer.valueOf(dVarArr13[3].a), 3);
                hashMap.put(Integer.valueOf(dVarArr13[4].a), 7);
                hashMap.put(Integer.valueOf(dVarArr13[5].a), 8);
                Pattern.compile(".*[1-9].*");
                Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
                return;
            }
        }
    }

    public a(InputStream inputStream) throws IOException {
        boolean z2;
        d[][] dVarArr = W;
        this.f8754e = new HashMap[dVarArr.length];
        this.f8755f = new HashSet(dVarArr.length);
        this.f8756g = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(inputStream, "inputStream cannot be null");
        if (inputStream instanceof AssetManager.AssetInputStream) {
            this.b = (AssetManager.AssetInputStream) inputStream;
            this.a = null;
        } else {
            if (inputStream instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) inputStream;
                try {
                    Os.lseek(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                    z2 = true;
                } catch (Exception unused) {
                    if (f8746q) {
                        Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                    }
                    z2 = false;
                }
                if (z2) {
                    this.b = null;
                    this.a = fileInputStream.getFD();
                }
            }
            this.b = null;
            this.a = null;
        }
        for (int i2 = 0; i2 < W.length; i2++) {
            try {
                try {
                    this.f8754e[i2] = new HashMap<>();
                } catch (IOException e2) {
                    boolean z3 = f8746q;
                    if (z3) {
                        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 (!z3) {
                        return;
                    }
                }
            } finally {
                a();
                if (f8746q) {
                    s();
                }
            }
        }
        if (!this.f8753d) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            this.c = h(bufferedInputStream);
            inputStream = bufferedInputStream;
        }
        b bVar = new b(inputStream);
        if (!this.f8753d) {
            switch (this.c) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    l(bVar);
                    break;
                case 4:
                    g(bVar, 0, 0);
                    break;
                case 7:
                    i(bVar);
                    break;
                case 9:
                    k(bVar);
                    break;
                case 10:
                    m(bVar);
                    break;
                case 12:
                    f(bVar);
                    break;
                case 13:
                    j(bVar);
                    break;
                case 14:
                    o(bVar);
                    break;
            }
        } else {
            n(bVar);
        }
        w(bVar);
    }

    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 long[] c(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 boolean x(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 final void A() throws IOException {
        y(0, 5);
        y(0, 4);
        y(5, 4);
        c cVar = this.f8754e[1].get("PixelXDimension");
        c cVar2 = this.f8754e[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            this.f8754e[0].put("ImageWidth", cVar);
            this.f8754e[0].put("ImageLength", cVar2);
        }
        if (this.f8754e[4].isEmpty() && q(this.f8754e[5])) {
            HashMap<String, c>[] hashMapArr = this.f8754e;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (q(this.f8754e[4])) {
            return;
        }
        Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
    }

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

    public String d(String str) {
        c e2 = e(str);
        if (e2 != null) {
            if (!a0.contains(str)) {
                return e2.g(this.f8756g);
            }
            if (str.equals("GPSTimeStamp")) {
                int i2 = e2.a;
                if (i2 != 5 && i2 != 10) {
                    StringBuilder J2 = i.a.b.a.a.J("GPS Timestamp format is not rational. format=");
                    J2.append(e2.a);
                    Log.w("ExifInterface", J2.toString());
                    return null;
                }
                e[] eVarArr = (e[]) e2.h(this.f8756g);
                if (eVarArr != null && eVarArr.length == 3) {
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVarArr[0].a) / ((float) eVarArr[0].b))), Integer.valueOf((int) (((float) eVarArr[1].a) / ((float) eVarArr[1].b))), Integer.valueOf((int) (((float) eVarArr[2].a) / ((float) eVarArr[2].b))));
                }
                StringBuilder J3 = i.a.b.a.a.J("Invalid GPS Timestamp array. array=");
                J3.append(Arrays.toString(eVarArr));
                Log.w("ExifInterface", J3.toString());
                return null;
            }
            try {
                return Double.toString(e2.e(this.f8756g));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public final c e(String str) {
        if ("ISOSpeedRatings".equals(str)) {
            if (f8746q) {
                Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str = "PhotographicSensitivity";
        }
        for (int i2 = 0; i2 < W.length; i2++) {
            c cVar = this.f8754e[i2].get(str);
            if (cVar != null) {
                return cVar;
            }
        }
        return null;
    }

    public final void f(b bVar) throws IOException {
        String str;
        String str2;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new C0067a(this, bVar));
            } else {
                FileDescriptor fileDescriptor = this.a;
                if (fileDescriptor == null) {
                    return;
                }
                mediaMetadataRetriever.setDataSource(fileDescriptor);
            }
            String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
            String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
            String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
            String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
            String str3 = null;
            if ("yes".equals(extractMetadata3)) {
                str3 = mediaMetadataRetriever.extractMetadata(29);
                str = mediaMetadataRetriever.extractMetadata(30);
                str2 = mediaMetadataRetriever.extractMetadata(31);
            } else if ("yes".equals(extractMetadata4)) {
                str3 = mediaMetadataRetriever.extractMetadata(18);
                str = mediaMetadataRetriever.extractMetadata(19);
                str2 = mediaMetadataRetriever.extractMetadata(24);
            } else {
                str = null;
                str2 = null;
            }
            if (str3 != null) {
                this.f8754e[0].put("ImageWidth", c.d(Integer.parseInt(str3), this.f8756g));
            }
            if (str != null) {
                this.f8754e[0].put("ImageLength", c.d(Integer.parseInt(str), this.f8756g));
            }
            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.f8754e[0].put("Orientation", c.d(i2, this.f8756g));
            }
            if (extractMetadata != null && extractMetadata2 != null) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 > 6) {
                    bVar.c(parseInt2);
                    byte[] bArr = new byte[6];
                    if (bVar.read(bArr) == 6) {
                        int i3 = parseInt2 + 6;
                        int i4 = parseInt3 - 6;
                        if (Arrays.equals(bArr, d0)) {
                            byte[] bArr2 = new byte[i4];
                            if (bVar.read(bArr2) == i4) {
                                this.f8761l = i3;
                                u(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 (f8746q) {
                Log.d("ExifInterface", "Heif meta: " + str3 + "x" + str + ", rotation " + str2);
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void g(b bVar, int i2, int i3) throws IOException {
        if (f8746q) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.f8771j = ByteOrder.BIG_ENDIAN;
        bVar.c(i2);
        byte readByte = bVar.readByte();
        byte b2 = -1;
        if (readByte == -1) {
            int i4 = 1;
            int i5 = i2 + 1;
            if (bVar.readByte() != -40) {
                StringBuilder J2 = i.a.b.a.a.J("Invalid marker: ");
                J2.append(Integer.toHexString(readByte & 255));
                throw new IOException(J2.toString());
            }
            int i6 = i5 + 1;
            while (true) {
                byte readByte2 = bVar.readByte();
                if (readByte2 == b2) {
                    int i7 = i6 + i4;
                    byte readByte3 = bVar.readByte();
                    boolean z2 = f8746q;
                    if (z2) {
                        StringBuilder J3 = i.a.b.a.a.J("Found JPEG segment indicator: ");
                        J3.append(Integer.toHexString(readByte3 & 255));
                        Log.d("ExifInterface", J3.toString());
                    }
                    int i8 = i7 + i4;
                    if (readByte3 != -39 && readByte3 != -38) {
                        int readUnsignedShort = bVar.readUnsignedShort() - 2;
                        int i9 = i8 + 2;
                        if (z2) {
                            StringBuilder J4 = i.a.b.a.a.J("JPEG segment: ");
                            J4.append(Integer.toHexString(readByte3 & 255));
                            J4.append(" (length: ");
                            J4.append(readUnsignedShort + 2);
                            J4.append(")");
                            Log.d("ExifInterface", J4.toString());
                        }
                        if (readUnsignedShort < 0) {
                            throw new IOException("Invalid length");
                        }
                        if (readByte3 == -31) {
                            byte[] bArr = new byte[readUnsignedShort];
                            bVar.readFully(bArr);
                            int i10 = i9 + readUnsignedShort;
                            byte[] bArr2 = d0;
                            if (x(bArr, bArr2)) {
                                byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                                this.f8761l = i9 + bArr2.length;
                                u(copyOfRange, i3);
                            } else {
                                byte[] bArr3 = e0;
                                if (x(bArr, bArr3)) {
                                    int length = i9 + bArr3.length;
                                    byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                                    if (d("Xmp") == null) {
                                        this.f8754e[0].put("Xmp", new c(1, copyOfRange2.length, length, copyOfRange2));
                                    }
                                }
                            }
                            i9 = i10;
                        } else if (readByte3 != -2) {
                            switch (readByte3) {
                                default:
                                    switch (readByte3) {
                                        default:
                                            switch (readByte3) {
                                                default:
                                                    switch (readByte3) {
                                                    }
                                                case -55:
                                                case -54:
                                                case -53:
                                                    if (bVar.skipBytes(i4) == i4) {
                                                        this.f8754e[i3].put("ImageLength", c.b(bVar.readUnsignedShort(), this.f8756g));
                                                        this.f8754e[i3].put("ImageWidth", c.b(bVar.readUnsignedShort(), this.f8756g));
                                                        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");
                                }
                                i6 = i9 + readUnsignedShort;
                                b2 = -1;
                                i4 = 1;
                            } else {
                                throw new IOException("Invalid length");
                            }
                        } else {
                            byte[] bArr4 = new byte[readUnsignedShort];
                            if (bVar.read(bArr4) == readUnsignedShort) {
                                if (d("UserComment") == null) {
                                    this.f8754e[i4].put("UserComment", c.a(new String(bArr4, c0)));
                                }
                            } else {
                                throw new IOException("Invalid exif");
                            }
                        }
                        readUnsignedShort = 0;
                        if (readUnsignedShort < 0) {
                        }
                    }
                } else {
                    StringBuilder J5 = i.a.b.a.a.J("Invalid marker:");
                    J5.append(Integer.toHexString(readByte2 & 255));
                    throw new IOException(J5.toString());
                }
            }
        } else {
            StringBuilder J6 = i.a.b.a.a.J("Invalid marker: ");
            J6.append(Integer.toHexString(readByte & 255));
            throw new IOException(J6.toString());
        }
    }

    public final int h(BufferedInputStream bufferedInputStream) throws IOException {
        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 = f8751v;
            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, f8752w)) {
                    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, x)) {
                                    z9 = true;
                                } else if (Arrays.equals(bArr4, y)) {
                                    z10 = true;
                                }
                                if (z9 && z10) {
                                    bVar2.close();
                                    z4 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e2) {
                e = e2;
                try {
                    if (f8746q) {
                        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 t2 = t(bVar4);
                this.f8756g = t2;
                bVar4.f8771j = t2;
                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 t3 = t(bVar7);
                    this.f8756g = t3;
                    bVar7.f8771j = t3;
                    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 = B;
                    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 = F;
                    if (i5 >= bArr6.length) {
                        int i6 = 0;
                        while (true) {
                            byte[] bArr7 = G;
                            if (i6 >= bArr7.length) {
                                z8 = true;
                                break;
                            } else if (bArr[F.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 i(b bVar) throws IOException {
        l(bVar);
        c cVar = this.f8754e[1].get("MakerNote");
        if (cVar != null) {
            b bVar2 = new b(cVar.c);
            bVar2.f8771j = this.f8756g;
            byte[] bArr = z;
            byte[] bArr2 = new byte[bArr.length];
            bVar2.readFully(bArr2);
            bVar2.c(0L);
            byte[] bArr3 = A;
            byte[] bArr4 = new byte[bArr3.length];
            bVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                bVar2.c(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                bVar2.c(12L);
            }
            v(bVar2, 6);
            c cVar2 = this.f8754e[7].get("PreviewImageStart");
            c cVar3 = this.f8754e[7].get("PreviewImageLength");
            if (cVar2 != null && cVar3 != null) {
                this.f8754e[5].put("JPEGInterchangeFormat", cVar2);
                this.f8754e[5].put("JPEGInterchangeFormatLength", cVar3);
            }
            c cVar4 = this.f8754e[8].get("AspectFrame");
            if (cVar4 != null) {
                int[] iArr = (int[]) cVar4.h(this.f8756g);
                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;
                    }
                    c d2 = c.d(i2, this.f8756g);
                    c d3 = c.d(i3, this.f8756g);
                    this.f8754e[0].put("ImageWidth", d2);
                    this.f8754e[0].put("ImageLength", d3);
                    return;
                }
                StringBuilder J2 = i.a.b.a.a.J("Invalid aspect frame values. frame=");
                J2.append(Arrays.toString(iArr));
                Log.w("ExifInterface", J2.toString());
            }
        }
    }

    public final void j(b bVar) throws IOException {
        if (f8746q) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.f8771j = ByteOrder.BIG_ENDIAN;
        byte[] bArr = B;
        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, D)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (Arrays.equals(bArr2, E)) {
                        return;
                    }
                    if (Arrays.equals(bArr2, C)) {
                        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.f8761l = i3;
                                u(bArr3, 0);
                                A();
                                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 k(b bVar) throws IOException {
        bVar.skipBytes(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        bVar.read(bArr);
        bVar.skipBytes(4);
        bVar.read(bArr2);
        int i2 = ByteBuffer.wrap(bArr).getInt();
        int i3 = ByteBuffer.wrap(bArr2).getInt();
        g(bVar, i2, 5);
        bVar.c(i3);
        bVar.f8771j = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (f8746q) {
            i.a.b.a.a.h0("numberOfDirectoryEntry: ", readInt, "ExifInterface");
        }
        for (int i4 = 0; i4 < readInt; i4++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == R.a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c d2 = c.d(readShort, this.f8756g);
                c d3 = c.d(readShort2, this.f8756g);
                this.f8754e[0].put("ImageLength", d2);
                this.f8754e[0].put("ImageWidth", d3);
                if (f8746q) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    public final void l(b bVar) throws IOException {
        c cVar;
        r(bVar, bVar.available());
        v(bVar, 0);
        z(bVar, 0);
        z(bVar, 5);
        z(bVar, 4);
        A();
        if (this.c != 8 || (cVar = this.f8754e[1].get("MakerNote")) == null) {
            return;
        }
        b bVar2 = new b(cVar.c);
        bVar2.f8771j = this.f8756g;
        bVar2.c(6L);
        v(bVar2, 9);
        c cVar2 = this.f8754e[9].get("ColorSpace");
        if (cVar2 != null) {
            this.f8754e[1].put("ColorSpace", cVar2);
        }
    }

    public final void m(b bVar) throws IOException {
        l(bVar);
        if (this.f8754e[0].get("JpgFromRaw") != null) {
            g(bVar, this.f8765p, 5);
        }
        c cVar = this.f8754e[0].get("ISO");
        c cVar2 = this.f8754e[1].get("PhotographicSensitivity");
        if (cVar == null || cVar2 != null) {
            return;
        }
        this.f8754e[1].put("PhotographicSensitivity", cVar);
    }

    public final void n(b bVar) throws IOException {
        byte[] bArr = d0;
        bVar.skipBytes(bArr.length);
        byte[] bArr2 = new byte[bVar.available()];
        bVar.readFully(bArr2);
        this.f8761l = bArr.length;
        u(bArr2, 0);
    }

    public final void o(b bVar) throws IOException {
        if (f8746q) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.f8771j = ByteOrder.LITTLE_ENDIAN;
        bVar.skipBytes(F.length);
        int readInt = bVar.readInt() + 8;
        int skipBytes = bVar.skipBytes(G.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(H, bArr)) {
                        byte[] bArr2 = new byte[readInt2];
                        if (bVar.read(bArr2) == readInt2) {
                            this.f8761l = i2;
                            u(bArr2, 0);
                            this.f8761l = i2;
                            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 final void p(b bVar, HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int f2 = cVar.f(this.f8756g);
        int f3 = cVar2.f(this.f8756g);
        if (this.c == 7) {
            f2 += this.f8762m;
        }
        int min = Math.min(f3, bVar.f8772k - f2);
        if (f2 > 0 && min > 0) {
            int i2 = this.f8761l + f2;
            this.f8758i = i2;
            this.f8759j = min;
            if (this.b == null && this.a == null) {
                bVar.c(i2);
                bVar.readFully(new byte[min]);
            }
        }
        if (f8746q) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + f2 + ", length: " + min);
        }
    }

    public final boolean q(HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("ImageLength");
        c cVar2 = (c) hashMap.get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            return false;
        }
        return cVar.f(this.f8756g) <= 512 && cVar2.f(this.f8756g) <= 512;
    }

    public final void r(b bVar, int i2) throws IOException {
        ByteOrder t2 = t(bVar);
        this.f8756g = t2;
        bVar.f8771j = t2;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i3 = this.c;
        if (i3 != 7 && i3 != 10 && readUnsignedShort != 42) {
            StringBuilder J2 = i.a.b.a.a.J("Invalid start code: ");
            J2.append(Integer.toHexString(readUnsignedShort));
            throw new IOException(J2.toString());
        }
        int readInt = bVar.readInt();
        if (readInt >= 8 && readInt < i2) {
            int i4 = readInt - 8;
            if (i4 > 0 && bVar.skipBytes(i4) != i4) {
                throw new IOException(i.a.b.a.a.i("Couldn't jump to first Ifd: ", i4));
            }
            return;
        }
        throw new IOException(i.a.b.a.a.i("Invalid first Ifd offset: ", readInt));
    }

    public final void s() {
        for (int i2 = 0; i2 < this.f8754e.length; i2++) {
            StringBuilder K2 = i.a.b.a.a.K("The size of tag group[", i2, "]: ");
            K2.append(this.f8754e[i2].size());
            Log.d("ExifInterface", K2.toString());
            for (Map.Entry<String, c> entry : this.f8754e[i2].entrySet()) {
                c value = entry.getValue();
                StringBuilder J2 = i.a.b.a.a.J("tagName: ");
                J2.append(entry.getKey());
                J2.append(", tagType: ");
                J2.append(value.toString());
                J2.append(", tagValue: '");
                J2.append(value.g(this.f8756g));
                J2.append("'");
                Log.d("ExifInterface", J2.toString());
            }
        }
    }

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

    public final void u(byte[] bArr, int i2) throws IOException {
        b bVar = new b(bArr);
        r(bVar, bArr.length);
        v(bVar, i2);
    }

    public final void v(b bVar, int i2) throws IOException {
        short s2;
        short s3;
        int[] iArr;
        boolean z2;
        long j2;
        boolean z3;
        int i3;
        int i4;
        int i5;
        d dVar;
        int readUnsignedShort;
        long j3;
        this.f8755f.add(Integer.valueOf(bVar.f8773l));
        if (bVar.f8773l + 2 > bVar.f8772k) {
            return;
        }
        short readShort = bVar.readShort();
        if (f8746q) {
            i.a.b.a.a.h0("numberOfDirectoryEntry: ", readShort, "ExifInterface");
        }
        if ((readShort * 12) + bVar.f8773l > bVar.f8772k || 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 j4 = bVar.f8773l + 4;
            d dVar2 = Y[i2].get(Integer.valueOf(readUnsignedShort2));
            boolean z4 = f8746q;
            if (z4) {
                Object[] objArr = new Object[5];
                objArr[c2] = Integer.valueOf(i2);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                objArr[2] = dVar2 != null ? dVar2.b : 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 (dVar2 == null) {
                if (z4) {
                    i.a.b.a.a.h0("Skip the tag entry since tag number is not defined: ", readUnsignedShort2, "ExifInterface");
                }
                s2 = readShort;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < K.length) {
                        int i6 = dVar2.c;
                        if (i6 == 7 || readUnsignedShort3 == 7 || i6 == readUnsignedShort3 || (i3 = dVar2.f8774d) == readUnsignedShort3) {
                            s2 = readShort;
                        } else {
                            s2 = readShort;
                            if (((i6 != 4 && i3 != 4) || readUnsignedShort3 != 3) && (((i6 != 9 && i3 != 9) || readUnsignedShort3 != 8) && ((i6 != 12 && i3 != 12) || readUnsignedShort3 != 11))) {
                                z2 = false;
                                if (!z2) {
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i6;
                                    }
                                    s3 = s4;
                                    j2 = readInt * iArr[readUnsignedShort3];
                                    if (j2 < 0 || j2 > 2147483647L) {
                                        if (z4) {
                                            i.a.b.a.a.h0("Skip the tag entry since the number of components is invalid: ", readInt, "ExifInterface");
                                        }
                                        z3 = false;
                                    } else {
                                        z3 = true;
                                    }
                                    if (!z3) {
                                        bVar.c(j4);
                                    } else {
                                        if (j2 > 4) {
                                            int readInt2 = bVar.readInt();
                                            if (z4) {
                                                i.a.b.a.a.h0("seek to data offset: ", readInt2, "ExifInterface");
                                            }
                                            int i7 = this.c;
                                            i4 = readUnsignedShort3;
                                            if (i7 == 7) {
                                                if ("MakerNote".equals(dVar2.b)) {
                                                    this.f8762m = readInt2;
                                                } else if (i2 == 6 && "ThumbnailImage".equals(dVar2.b)) {
                                                    this.f8763n = readInt2;
                                                    this.f8764o = readInt;
                                                    c d2 = c.d(6, this.f8756g);
                                                    j3 = j4;
                                                    c b2 = c.b(this.f8763n, this.f8756g);
                                                    i5 = readInt;
                                                    c b3 = c.b(this.f8764o, this.f8756g);
                                                    this.f8754e[4].put("Compression", d2);
                                                    this.f8754e[4].put("JPEGInterchangeFormat", b2);
                                                    this.f8754e[4].put("JPEGInterchangeFormatLength", b3);
                                                }
                                                j3 = j4;
                                                i5 = readInt;
                                            } else {
                                                j3 = j4;
                                                i5 = readInt;
                                                if (i7 == 10 && "JpgFromRaw".equals(dVar2.b)) {
                                                    this.f8765p = readInt2;
                                                }
                                            }
                                            long j5 = readInt2;
                                            dVar = dVar2;
                                            if (j5 + j2 <= bVar.f8772k) {
                                                bVar.c(j5);
                                                j4 = j3;
                                            } else {
                                                if (z4) {
                                                    i.a.b.a.a.h0("Skip the tag entry since data offset is invalid: ", readInt2, "ExifInterface");
                                                }
                                                bVar.c(j3);
                                            }
                                        } else {
                                            i4 = readUnsignedShort3;
                                            i5 = readInt;
                                            dVar = dVar2;
                                        }
                                        Integer num = b0.get(Integer.valueOf(readUnsignedShort2));
                                        if (z4) {
                                            Log.d("ExifInterface", "nextIfdType: " + num + " byteCount: " + j2);
                                        }
                                        if (num != null) {
                                            long j6 = -1;
                                            int i8 = i4;
                                            if (i8 == 3) {
                                                readUnsignedShort = bVar.readUnsignedShort();
                                            } else {
                                                if (i8 == 4) {
                                                    j6 = 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(j6), dVar.b));
                                                }
                                                if (j6 > 0 || j6 >= bVar.f8772k) {
                                                    if (z4) {
                                                        Log.d("ExifInterface", "Skip jump into the IFD since its offset is invalid: " + j6);
                                                    }
                                                } else if (!this.f8755f.contains(Integer.valueOf((int) j6))) {
                                                    bVar.c(j6);
                                                    v(bVar, num.intValue());
                                                } else if (z4) {
                                                    Log.d("ExifInterface", "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j6 + ")");
                                                }
                                                bVar.c(j4);
                                            }
                                            j6 = readUnsignedShort;
                                            if (z4) {
                                            }
                                            if (j6 > 0) {
                                            }
                                            if (z4) {
                                            }
                                            bVar.c(j4);
                                        } else {
                                            byte[] bArr = new byte[(int) j2];
                                            bVar.readFully(bArr);
                                            long j7 = j4;
                                            d dVar3 = dVar;
                                            c cVar = new c(i4, i5, bVar.f8773l + this.f8761l, bArr);
                                            this.f8754e[i2].put(dVar3.b, cVar);
                                            if ("DNGVersion".equals(dVar3.b)) {
                                                this.c = 3;
                                            }
                                            if ((("Make".equals(dVar3.b) || "Model".equals(dVar3.b)) && cVar.g(this.f8756g).contains("PENTAX")) || ("Compression".equals(dVar3.b) && cVar.f(this.f8756g) == 65535)) {
                                                this.c = 8;
                                            }
                                            if (bVar.f8773l != j7) {
                                                bVar.c(j7);
                                            }
                                        }
                                    }
                                    s4 = (short) (s3 + 1);
                                    c2 = 0;
                                    readShort = s2;
                                } else if (z4) {
                                    StringBuilder J2 = i.a.b.a.a.J("Skip the tag entry since data format (");
                                    J2.append(J[readUnsignedShort3]);
                                    J2.append(") is unexpected for tag: ");
                                    J2.append(dVar2.b);
                                    Log.d("ExifInterface", J2.toString());
                                }
                            }
                        }
                        z2 = true;
                        if (!z2) {
                        }
                    }
                }
                s2 = readShort;
                s3 = s4;
                if (z4) {
                    i.a.b.a.a.h0("Skip the tag entry since data format is invalid: ", readUnsignedShort3, "ExifInterface");
                }
                z3 = false;
                j2 = 0;
                if (!z3) {
                }
                s4 = (short) (s3 + 1);
                c2 = 0;
                readShort = s2;
            }
            s3 = s4;
            z3 = false;
            j2 = 0;
            if (!z3) {
            }
            s4 = (short) (s3 + 1);
            c2 = 0;
            readShort = s2;
        }
        if (bVar.f8773l + 4 <= bVar.f8772k) {
            int readInt3 = bVar.readInt();
            boolean z5 = f8746q;
            if (z5) {
                Log.d("ExifInterface", String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
            }
            long j8 = readInt3;
            if (j8 <= 0 || readInt3 >= bVar.f8772k) {
                if (z5) {
                    i.a.b.a.a.h0("Stop reading file since a wrong offset may cause an infinite loop: ", readInt3, "ExifInterface");
                }
            } else if (this.f8755f.contains(Integer.valueOf(readInt3))) {
                if (z5) {
                    i.a.b.a.a.h0("Stop reading file since re-reading an IFD may cause an infinite loop: ", readInt3, "ExifInterface");
                }
            } else {
                bVar.c(j8);
                if (this.f8754e[4].isEmpty()) {
                    v(bVar, 4);
                } else if (this.f8754e[5].isEmpty()) {
                    v(bVar, 5);
                }
            }
        }
    }

    public final void w(b bVar) throws IOException {
        boolean z2;
        c cVar;
        int f2;
        HashMap<String, c> hashMap = this.f8754e[4];
        c cVar2 = hashMap.get("Compression");
        if (cVar2 != null) {
            int f3 = cVar2.f(this.f8756g);
            this.f8760k = f3;
            if (f3 != 1) {
                if (f3 == 6) {
                    p(bVar, hashMap);
                    return;
                } else if (f3 != 7) {
                    return;
                }
            }
            c cVar3 = hashMap.get("BitsPerSample");
            if (cVar3 != null) {
                int[] iArr = (int[]) cVar3.h(this.f8756g);
                int[] iArr2 = f8749t;
                if (Arrays.equals(iArr2, iArr) || (this.c == 3 && (cVar = hashMap.get("PhotometricInterpretation")) != null && (((f2 = cVar.f(this.f8756g)) == 1 && Arrays.equals(iArr, f8750u)) || (f2 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z2 = true;
                    if (z2) {
                        return;
                    }
                    c cVar4 = hashMap.get("StripOffsets");
                    c cVar5 = hashMap.get("StripByteCounts");
                    if (cVar4 == null || cVar5 == null) {
                        return;
                    }
                    long[] c2 = c(cVar4.h(this.f8756g));
                    long[] c3 = c(cVar5.h(this.f8756g));
                    if (c2 != null && c2.length != 0) {
                        if (c3 != null && c3.length != 0) {
                            if (c2.length != c3.length) {
                                Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                                return;
                            }
                            long j2 = 0;
                            for (long j3 : c3) {
                                j2 += j3;
                            }
                            int i2 = (int) j2;
                            byte[] bArr = new byte[i2];
                            this.f8757h = true;
                            int i3 = 0;
                            int i4 = 0;
                            for (int i5 = 0; i5 < c2.length; i5++) {
                                int i6 = (int) c2[i5];
                                int i7 = (int) c3[i5];
                                if (i5 < c2.length - 1 && i6 + i7 != c2[i5 + 1]) {
                                    this.f8757h = false;
                                }
                                int i8 = i6 - i3;
                                if (i8 < 0) {
                                    Log.d("ExifInterface", "Invalid strip offset value");
                                }
                                bVar.c(i8);
                                int i9 = i3 + i8;
                                byte[] bArr2 = new byte[i7];
                                bVar.read(bArr2);
                                i3 = i9 + i7;
                                System.arraycopy(bArr2, 0, bArr, i4, i7);
                                i4 += i7;
                            }
                            if (this.f8757h) {
                                this.f8758i = ((int) c2[0]) + this.f8761l;
                                this.f8759j = i2;
                                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 (f8746q) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z2 = false;
            if (z2) {
            }
        } else {
            this.f8760k = 6;
            p(bVar, hashMap);
        }
    }

    public final void y(int i2, int i3) throws IOException {
        if (!this.f8754e[i2].isEmpty() && !this.f8754e[i3].isEmpty()) {
            c cVar = this.f8754e[i2].get("ImageLength");
            c cVar2 = this.f8754e[i2].get("ImageWidth");
            c cVar3 = this.f8754e[i3].get("ImageLength");
            c cVar4 = this.f8754e[i3].get("ImageWidth");
            if (cVar == null || cVar2 == null) {
                if (f8746q) {
                    Log.d("ExifInterface", "First image does not contain valid size information");
                }
            } else if (cVar3 != null && cVar4 != null) {
                int f2 = cVar.f(this.f8756g);
                int f3 = cVar2.f(this.f8756g);
                int f4 = cVar3.f(this.f8756g);
                int f5 = cVar4.f(this.f8756g);
                if (f2 >= f4 || f3 >= f5) {
                    return;
                }
                HashMap<String, c>[] hashMapArr = this.f8754e;
                HashMap<String, c> hashMap = hashMapArr[i2];
                hashMapArr[i2] = hashMapArr[i3];
                hashMapArr[i3] = hashMap;
            } else if (f8746q) {
                Log.d("ExifInterface", "Second image does not contain valid size information");
            }
        } else if (f8746q) {
            Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
        }
    }

    public final void z(b bVar, int i2) throws IOException {
        c cVar;
        c d2;
        c d3;
        c cVar2 = this.f8754e[i2].get("DefaultCropSize");
        c cVar3 = this.f8754e[i2].get("SensorTopBorder");
        c cVar4 = this.f8754e[i2].get("SensorLeftBorder");
        c cVar5 = this.f8754e[i2].get("SensorBottomBorder");
        c cVar6 = this.f8754e[i2].get("SensorRightBorder");
        if (cVar2 != null) {
            if (cVar2.a == 5) {
                e[] eVarArr = (e[]) cVar2.h(this.f8756g);
                if (eVarArr != null && eVarArr.length == 2) {
                    d2 = c.c(eVarArr[0], this.f8756g);
                    d3 = c.c(eVarArr[1], this.f8756g);
                } else {
                    StringBuilder J2 = i.a.b.a.a.J("Invalid crop size values. cropSize=");
                    J2.append(Arrays.toString(eVarArr));
                    Log.w("ExifInterface", J2.toString());
                    return;
                }
            } else {
                int[] iArr = (int[]) cVar2.h(this.f8756g);
                if (iArr != null && iArr.length == 2) {
                    d2 = c.d(iArr[0], this.f8756g);
                    d3 = c.d(iArr[1], this.f8756g);
                } else {
                    StringBuilder J3 = i.a.b.a.a.J("Invalid crop size values. cropSize=");
                    J3.append(Arrays.toString(iArr));
                    Log.w("ExifInterface", J3.toString());
                    return;
                }
            }
            this.f8754e[i2].put("ImageWidth", d2);
            this.f8754e[i2].put("ImageLength", d3);
        } else if (cVar3 != null && cVar4 != null && cVar5 != null && cVar6 != null) {
            int f2 = cVar3.f(this.f8756g);
            int f3 = cVar5.f(this.f8756g);
            int f4 = cVar6.f(this.f8756g);
            int f5 = cVar4.f(this.f8756g);
            if (f3 <= f2 || f4 <= f5) {
                return;
            }
            c d4 = c.d(f3 - f2, this.f8756g);
            c d5 = c.d(f4 - f5, this.f8756g);
            this.f8754e[i2].put("ImageLength", d4);
            this.f8754e[i2].put("ImageWidth", d5);
        } else {
            c cVar7 = this.f8754e[i2].get("ImageLength");
            c cVar8 = this.f8754e[i2].get("ImageWidth");
            if ((cVar7 == null || cVar8 == null) && (cVar = this.f8754e[i2].get("JPEGInterchangeFormat")) != null) {
                g(bVar, cVar.f(this.f8756g), i2);
            }
        }
    }

    public static class b extends InputStream implements DataInput {
        public static final ByteOrder f8768m = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder f8769n = ByteOrder.BIG_ENDIAN;
        public DataInputStream f8770i;
        public ByteOrder f8771j;
        public final int f8772k;
        public int f8773l;

        public b(InputStream inputStream) throws IOException {
            ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
            this.f8771j = byteOrder;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f8770i = dataInputStream;
            int available = dataInputStream.available();
            this.f8772k = available;
            this.f8773l = 0;
            this.f8770i.mark(available);
            this.f8771j = byteOrder;
        }

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

        @Override
        public int available() throws IOException {
            return this.f8770i.available();
        }

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

        @Override
        public int read() throws IOException {
            this.f8773l++;
            return this.f8770i.read();
        }

        @Override
        public boolean readBoolean() throws IOException {
            this.f8773l++;
            return this.f8770i.readBoolean();
        }

        @Override
        public byte readByte() throws IOException {
            int i2 = this.f8773l + 1;
            this.f8773l = i2;
            if (i2 <= this.f8772k) {
                int read = this.f8770i.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public char readChar() throws IOException {
            this.f8773l += 2;
            return this.f8770i.readChar();
        }

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

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

        @Override
        public void readFully(byte[] bArr, int i2, int i3) throws IOException {
            int i4 = this.f8773l + i3;
            this.f8773l = i4;
            if (i4 <= this.f8772k) {
                if (this.f8770i.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() throws IOException {
            int i2 = this.f8773l + 4;
            this.f8773l = i2;
            if (i2 <= this.f8772k) {
                int read = this.f8770i.read();
                int read2 = this.f8770i.read();
                int read3 = this.f8770i.read();
                int read4 = this.f8770i.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.f8771j;
                    if (byteOrder == f8768m) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f8769n) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    StringBuilder J = i.a.b.a.a.J("Invalid byte order: ");
                    J.append(this.f8771j);
                    throw new IOException(J.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

        @Override
        public long readLong() throws IOException {
            int i2 = this.f8773l + 8;
            this.f8773l = i2;
            if (i2 <= this.f8772k) {
                int read = this.f8770i.read();
                int read2 = this.f8770i.read();
                int read3 = this.f8770i.read();
                int read4 = this.f8770i.read();
                int read5 = this.f8770i.read();
                int read6 = this.f8770i.read();
                int read7 = this.f8770i.read();
                int read8 = this.f8770i.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.f8771j;
                    if (byteOrder == f8768m) {
                        return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f8769n) {
                        return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                    }
                    StringBuilder J = i.a.b.a.a.J("Invalid byte order: ");
                    J.append(this.f8771j);
                    throw new IOException(J.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public short readShort() throws IOException {
            int i2 = this.f8773l + 2;
            this.f8773l = i2;
            if (i2 <= this.f8772k) {
                int read = this.f8770i.read();
                int read2 = this.f8770i.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f8771j;
                    if (byteOrder == f8768m) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == f8769n) {
                        return (short) ((read << 8) + read2);
                    }
                    StringBuilder J = i.a.b.a.a.J("Invalid byte order: ");
                    J.append(this.f8771j);
                    throw new IOException(J.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public String readUTF() throws IOException {
            this.f8773l += 2;
            return this.f8770i.readUTF();
        }

        @Override
        public int readUnsignedByte() throws IOException {
            this.f8773l++;
            return this.f8770i.readUnsignedByte();
        }

        @Override
        public int readUnsignedShort() throws IOException {
            int i2 = this.f8773l + 2;
            this.f8773l = i2;
            if (i2 <= this.f8772k) {
                int read = this.f8770i.read();
                int read2 = this.f8770i.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f8771j;
                    if (byteOrder == f8768m) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == f8769n) {
                        return (read << 8) + read2;
                    }
                    StringBuilder J = i.a.b.a.a.J("Invalid byte order: ");
                    J.append(this.f8771j);
                    throw new IOException(J.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public int skipBytes(int i2) throws IOException {
            int min = Math.min(i2, this.f8772k - this.f8773l);
            int i3 = 0;
            while (i3 < min) {
                i3 += this.f8770i.skipBytes(min - i3);
            }
            this.f8773l += i3;
            return i3;
        }

        @Override
        public int read(byte[] bArr, int i2, int i3) throws IOException {
            int read = this.f8770i.read(bArr, i2, i3);
            this.f8773l += read;
            return read;
        }

        @Override
        public void readFully(byte[] bArr) throws IOException {
            int length = this.f8773l + bArr.length;
            this.f8773l = length;
            if (length <= this.f8772k) {
                if (this.f8770i.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) throws IOException {
            this(new ByteArrayInputStream(bArr));
        }
    }

    public static class c {
        public final int a;
        public final int b;
        public final byte[] c;

        public c(int i2, int i3, long j2, byte[] bArr) {
            this.a = i2;
            this.b = i3;
            this.c = bArr;
        }

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

        public static c b(long j2, ByteOrder byteOrder) {
            long[] jArr = {j2};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.K[4] * 1]);
            wrap.order(byteOrder);
            for (int i2 = 0; i2 < 1; i2++) {
                wrap.putInt((int) jArr[i2]);
            }
            return new c(4, 1, wrap.array());
        }

        public static c c(e eVar, ByteOrder byteOrder) {
            e[] eVarArr = {eVar};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.K[5] * 1]);
            wrap.order(byteOrder);
            for (int i2 = 0; i2 < 1; i2++) {
                e eVar2 = eVarArr[i2];
                wrap.putInt((int) eVar2.a);
                wrap.putInt((int) eVar2.b);
            }
            return new c(5, 1, wrap.array());
        }

        public static c d(int i2, ByteOrder byteOrder) {
            int[] iArr = {i2};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.K[3] * 1]);
            wrap.order(byteOrder);
            for (int i3 = 0; i3 < 1; i3++) {
                wrap.putShort((short) iArr[i3]);
            }
            return new c(3, 1, wrap.array());
        }

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

        public Object h(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b;
            byte[] bArr;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(this.c);
                    try {
                        bVar.f8771j = byteOrder;
                        boolean z = true;
                        int i2 = 0;
                        switch (this.a) {
                            case 1:
                            case 6:
                                byte[] bArr2 = this.c;
                                if (bArr2.length == 1 && bArr2[0] >= 0 && bArr2[0] <= 1) {
                                    String str = new String(new char[]{(char) (this.c[0] + 48)});
                                    try {
                                        bVar.close();
                                    } catch (IOException e2) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e2);
                                    }
                                    return str;
                                }
                                String str2 = new String(this.c, a.c0);
                                try {
                                    bVar.close();
                                } catch (IOException e3) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e3);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (this.b >= a.L.length) {
                                    int i3 = 0;
                                    while (true) {
                                        bArr = a.L;
                                        if (i3 < bArr.length) {
                                            if (this.c[i3] != bArr[i3]) {
                                                z = false;
                                            } else {
                                                i3++;
                                            }
                                        }
                                    }
                                    if (z) {
                                        i2 = bArr.length;
                                    }
                                }
                                StringBuilder sb = new StringBuilder();
                                while (i2 < this.b && (b = this.c[i2]) != 0) {
                                    if (b >= 32) {
                                        sb.append((char) b);
                                    } 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.b];
                                while (i2 < this.b) {
                                    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.b];
                                while (i2 < this.b) {
                                    jArr[i2] = bVar.a();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e6) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e6);
                                }
                                return jArr;
                            case 5:
                                e[] eVarArr = new e[this.b];
                                while (i2 < this.b) {
                                    eVarArr[i2] = new e(bVar.a(), bVar.a());
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e7) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e7);
                                }
                                return eVarArr;
                            case 8:
                                int[] iArr2 = new int[this.b];
                                while (i2 < this.b) {
                                    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.b];
                                while (i2 < this.b) {
                                    iArr3[i2] = bVar.readInt();
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e9) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e9);
                                }
                                return iArr3;
                            case 10:
                                e[] eVarArr2 = new e[this.b];
                                while (i2 < this.b) {
                                    eVarArr2[i2] = new e(bVar.readInt(), bVar.readInt());
                                    i2++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e10) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                }
                                return eVarArr2;
                            case 11:
                                double[] dArr = new double[this.b];
                                while (i2 < this.b) {
                                    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.b];
                                while (i2 < this.b) {
                                    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 J = i.a.b.a.a.J("(");
            J.append(a.J[this.a]);
            J.append(", data length:");
            return i.a.b.a.a.w(J, this.c.length, ")");
        }

        public c(int i2, int i3, byte[] bArr) {
            this.a = i2;
            this.b = i3;
            this.c = bArr;
        }
    }

    public static class d {
        public final int a;
        public final String b;
        public final int c;
        public final int f8774d;

        public d(String str, int i2, int i3) {
            this.b = str;
            this.a = i2;
            this.c = i3;
            this.f8774d = -1;
        }

        public d(String str, int i2, int i3, int i4) {
            this.b = str;
            this.a = i2;
            this.c = i3;
            this.f8774d = i4;
        }
    }
}