CONECTA PRO v4.2.8版本的 MD5 值为:ad88cf9e66d8cdaae8c40233e50eb389

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


package r0;

import android.content.res.AssetManager;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.OsConstants;
import android.util.Log;
import j.i0;
import java.io.BufferedInputStream;
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.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
public final class g {
    public static final byte[] A;
    public static final String[] B;
    public static final int[] C;
    public static final byte[] D;
    public static final d E;
    public static final d[][] F;
    public static final d[] G;
    public static final HashMap[] H;
    public static final HashMap[] I;
    public static final HashSet J;
    public static final HashMap K;
    public static final Charset L;
    public static final byte[] M;
    public static final byte[] N;
    public static final boolean f8668l = Log.isLoggable("ExifInterface", 3);
    public static final int[] f8669m;
    public static final int[] f8670n;
    public static final byte[] f8671o;
    public static final byte[] f8672p;
    public static final byte[] f8673q;
    public static final byte[] f8674r;
    public static final byte[] f8675s;
    public static final byte[] f8676t;
    public static final byte[] f8677u;
    public static final byte[] f8678v;
    public static final byte[] f8679w;
    public static final byte[] f8680x;
    public static final byte[] f8681y;
    public static final byte[] f8682z;
    public final FileDescriptor f8683a;
    public final AssetManager.AssetInputStream f8684b;
    public int f8685c;
    public final HashMap[] f8686d;
    public final HashSet f8687e;
    public ByteOrder f8688f;
    public boolean f8689g;
    public int f8690h;
    public int f8691i;
    public int f8692j;
    public int f8693k;

    static {
        d[] dVarArr;
        Arrays.asList(1, 6, 3, 8);
        Arrays.asList(2, 7, 4, 5);
        f8669m = new int[]{8, 8, 8};
        f8670n = new int[]{8};
        f8671o = new byte[]{-1, -40, -1};
        f8672p = new byte[]{102, 116, 121, 112};
        f8673q = new byte[]{109, 105, 102, 49};
        f8674r = new byte[]{104, 101, 105, 99};
        f8675s = new byte[]{79, 76, 89, 77, 80, 0};
        f8676t = new byte[]{79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
        f8677u = new byte[]{-119, 80, 78, 71, 13, 10, 26, 10};
        f8678v = new byte[]{101, 88, 73, 102};
        f8679w = new byte[]{73, 72, 68, 82};
        f8680x = new byte[]{73, 69, 78, 68};
        f8681y = new byte[]{82, 73, 70, 70};
        f8682z = new byte[]{87, 69, 66, 80};
        A = new byte[]{69, 88, 73, 70};
        "VP8X".getBytes(Charset.defaultCharset());
        "VP8L".getBytes(Charset.defaultCharset());
        "VP8 ".getBytes(Charset.defaultCharset());
        "ANIM".getBytes(Charset.defaultCharset());
        "ANMF".getBytes(Charset.defaultCharset());
        B = new String[]{"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
        C = new int[]{0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
        D = new byte[]{65, 83, 67, 73, 73, 0, 0, 0};
        d[] dVarArr2 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d(256, 3, 4, "ImageWidth"), new d(257, 3, 4, "ImageLength"), 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(273, 3, 4, "StripOffsets"), new d("Orientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d(278, 3, 4, "RowsPerStrip"), new d(279, 3, 4, "StripByteCounts"), 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)};
        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(40962, 3, 4, "PixelXDimension"), new d(40963, 3, 4, "PixelYDimension"), 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(50720, 3, 4, "DefaultCropSize")};
        d[] dVarArr4 = {new d("GPSVersionID", 0, 1), new d("GPSLatitudeRef", 1, 2), new d(2, 5, 10, "GPSLatitude"), new d("GPSLongitudeRef", 3, 2), new d(4, 5, 10, "GPSLongitude"), 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)};
        d[] dVarArr5 = {new d("InteroperabilityIndex", 1, 2)};
        d[] dVarArr6 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d(256, 3, 4, "ThumbnailImageWidth"), new d(257, 3, 4, "ThumbnailImageLength"), 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(273, 3, 4, "StripOffsets"), new d("ThumbnailOrientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d(278, 3, 4, "RowsPerStrip"), new d(279, 3, 4, "StripByteCounts"), 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("Xmp", 700, 1), new d("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("DNGVersion", 50706, 1), new d(50720, 3, 4, "DefaultCropSize")};
        E = new d("StripOffsets", 273, 3);
        F = new d[][]{dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr6, dVarArr2, new d[]{new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)}, new d[]{new d("PreviewImageStart", 257, 4), new d("PreviewImageLength", 258, 4)}, new d[]{new d("AspectFrame", 4371, 3)}, new d[]{new d("ColorSpace", 55, 3)}};
        G = 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)};
        H = new HashMap[10];
        I = new HashMap[10];
        J = new HashSet(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        K = new HashMap();
        Charset forName = Charset.forName("US-ASCII");
        L = forName;
        M = "Exif\u0000\u0000".getBytes(forName);
        N = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        Locale locale = Locale.US;
        new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).setTimeZone(TimeZone.getTimeZone("UTC"));
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale).setTimeZone(TimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            d[][] dVarArr7 = F;
            if (i10 >= dVarArr7.length) {
                HashMap hashMap = K;
                d[] dVarArr8 = G;
                hashMap.put(Integer.valueOf(dVarArr8[0].f8662a), 5);
                hashMap.put(Integer.valueOf(dVarArr8[1].f8662a), 1);
                hashMap.put(Integer.valueOf(dVarArr8[2].f8662a), 2);
                hashMap.put(Integer.valueOf(dVarArr8[3].f8662a), 3);
                hashMap.put(Integer.valueOf(dVarArr8[4].f8662a), 7);
                hashMap.put(Integer.valueOf(dVarArr8[5].f8662a), 8);
                Pattern.compile(".*[1-9].*");
                Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})$");
                Pattern.compile("^(\\d{4}):(\\d{2}):(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                return;
            }
            H[i10] = new HashMap();
            I[i10] = new HashMap();
            for (d dVar : dVarArr7[i10]) {
                H[i10].put(Integer.valueOf(dVar.f8662a), dVar);
                I[i10].put(dVar.f8663b, dVar);
            }
            i10++;
        }
    }

    public g(InputStream inputStream) {
        boolean z10;
        d[][] dVarArr = F;
        this.f8686d = new HashMap[dVarArr.length];
        this.f8687e = new HashSet(dVarArr.length);
        this.f8688f = ByteOrder.BIG_ENDIAN;
        if (inputStream != null) {
            boolean z11 = inputStream instanceof AssetManager.AssetInputStream;
            boolean z12 = true;
            FileDescriptor fileDescriptor = null;
            boolean z13 = f8668l;
            if (z11) {
                this.f8684b = (AssetManager.AssetInputStream) inputStream;
            } else {
                if (inputStream instanceof FileInputStream) {
                    FileInputStream fileInputStream = (FileInputStream) inputStream;
                    try {
                        h.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                        z10 = true;
                    } catch (Exception unused) {
                        if (z13) {
                            Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                        }
                        z10 = false;
                    }
                    if (z10) {
                        this.f8684b = null;
                        fileDescriptor = fileInputStream.getFD();
                    }
                }
                this.f8684b = null;
            }
            this.f8683a = fileDescriptor;
            for (int i10 = 0; i10 < dVarArr.length; i10++) {
                try {
                    try {
                        this.f8686d[i10] = new HashMap();
                    } finally {
                        a();
                        if (z13) {
                            p();
                        }
                    }
                } catch (IOException | UnsupportedOperationException e10) {
                    if (z13) {
                        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.", e10);
                    }
                    if (!z13) {
                        return;
                    }
                }
            }
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            int f10 = f(bufferedInputStream);
            this.f8685c = f10;
            if ((f10 == 4 || f10 == 9 || f10 == 13 || f10 == 14) ? false : false) {
                f fVar = new f(bufferedInputStream);
                int i11 = this.f8685c;
                if (i11 == 12) {
                    d(fVar);
                } else if (i11 == 7) {
                    g(fVar);
                } else if (i11 == 10) {
                    k(fVar);
                } else {
                    j(fVar);
                }
                fVar.e(this.f8690h);
                u(fVar);
            } else {
                b bVar = new b(bufferedInputStream);
                int i12 = this.f8685c;
                if (i12 == 4) {
                    e(bVar, 0, 0);
                } else if (i12 == 13) {
                    h(bVar);
                } else if (i12 == 9) {
                    i(bVar);
                } else if (i12 == 14) {
                    l(bVar);
                }
            }
            a();
            if (!z13) {
                return;
            }
            return;
        }
        throw new NullPointerException("inputStream cannot be null");
    }

    public static ByteOrder q(b bVar) {
        short readShort = bVar.readShort();
        boolean z10 = f8668l;
        if (readShort == 18761) {
            if (z10) {
                Log.d("ExifInterface", "readExifSegment: Byte Align II");
            }
            return ByteOrder.LITTLE_ENDIAN;
        } else if (readShort == 19789) {
            if (z10) {
                Log.d("ExifInterface", "readExifSegment: Byte Align MM");
            }
            return ByteOrder.BIG_ENDIAN;
        } else {
            throw new IOException("Invalid byte order: " + Integer.toHexString(readShort));
        }
    }

    public final void a() {
        String b10 = b("DateTimeOriginal");
        HashMap[] hashMapArr = this.f8686d;
        if (b10 != null && b("DateTime") == null) {
            hashMapArr[0].put("DateTime", c.a(b10));
        }
        if (b("ImageWidth") == null) {
            hashMapArr[0].put("ImageWidth", c.b(0L, this.f8688f));
        }
        if (b("ImageLength") == null) {
            hashMapArr[0].put("ImageLength", c.b(0L, this.f8688f));
        }
        if (b("Orientation") == null) {
            hashMapArr[0].put("Orientation", c.b(0L, this.f8688f));
        }
        if (b("LightSource") == null) {
            hashMapArr[1].put("LightSource", c.b(0L, this.f8688f));
        }
    }

    public final String b(String str) {
        String str2;
        c c10 = c(str);
        if (c10 != null) {
            if (!J.contains(str)) {
                return c10.g(this.f8688f);
            }
            if (str.equals("GPSTimeStamp")) {
                int i10 = c10.f8658a;
                if (i10 != 5 && i10 != 10) {
                    str2 = i0.n("GPS Timestamp format is not rational. format=", i10);
                } else {
                    e[] eVarArr = (e[]) c10.h(this.f8688f);
                    if (eVarArr != null && eVarArr.length == 3) {
                        e eVar = eVarArr[0];
                        e eVar2 = eVarArr[1];
                        e eVar3 = eVarArr[2];
                        return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVar.f8666a) / ((float) eVar.f8667b))), Integer.valueOf((int) (((float) eVar2.f8666a) / ((float) eVar2.f8667b))), Integer.valueOf((int) (((float) eVar3.f8666a) / ((float) eVar3.f8667b))));
                    }
                    str2 = "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr);
                }
                Log.w("ExifInterface", str2);
                return null;
            }
            try {
                return Double.toString(c10.e(this.f8688f));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

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

    public final void d(f fVar) {
        String str;
        String str2;
        String str3;
        if (Build.VERSION.SDK_INT < 28) {
            throw new UnsupportedOperationException("Reading EXIF from HEIF files is supported from SDK 28 and above");
        }
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            try {
                i.a(mediaMetadataRetriever, new a(fVar));
                String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
                String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
                String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
                String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
                if ("yes".equals(extractMetadata3)) {
                    str = mediaMetadataRetriever.extractMetadata(29);
                    str2 = mediaMetadataRetriever.extractMetadata(30);
                    str3 = mediaMetadataRetriever.extractMetadata(31);
                } else if ("yes".equals(extractMetadata4)) {
                    str = mediaMetadataRetriever.extractMetadata(18);
                    str2 = mediaMetadataRetriever.extractMetadata(19);
                    str3 = mediaMetadataRetriever.extractMetadata(24);
                } else {
                    str = null;
                    str2 = null;
                    str3 = null;
                }
                HashMap[] hashMapArr = this.f8686d;
                if (str != null) {
                    hashMapArr[0].put("ImageWidth", c.d(Integer.parseInt(str), this.f8688f));
                }
                if (str2 != null) {
                    hashMapArr[0].put("ImageLength", c.d(Integer.parseInt(str2), this.f8688f));
                }
                if (str3 != null) {
                    int parseInt = Integer.parseInt(str3);
                    hashMapArr[0].put("Orientation", c.d(parseInt != 90 ? parseInt != 180 ? parseInt != 270 ? 1 : 8 : 3 : 6, this.f8688f));
                }
                if (extractMetadata != null && extractMetadata2 != null) {
                    int parseInt2 = Integer.parseInt(extractMetadata);
                    int parseInt3 = Integer.parseInt(extractMetadata2);
                    if (parseInt3 <= 6) {
                        throw new IOException("Invalid exif length");
                    }
                    fVar.e(parseInt2);
                    byte[] bArr = new byte[6];
                    if (fVar.read(bArr) != 6) {
                        throw new IOException("Can't read identifier");
                    }
                    int i10 = parseInt2 + 6;
                    int i11 = parseInt3 - 6;
                    if (!Arrays.equals(bArr, M)) {
                        throw new IOException("Invalid identifier");
                    }
                    byte[] bArr2 = new byte[i11];
                    if (fVar.read(bArr2) != i11) {
                        throw new IOException("Can't read exif");
                    }
                    this.f8690h = i10;
                    r(0, bArr2);
                }
                if (f8668l) {
                    Log.d("ExifInterface", "Heif meta: " + str + "x" + str2 + ", rotation " + str3);
                }
            } catch (RuntimeException unused) {
                throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported.");
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void e(b bVar, int i10, int i11) {
        byte readByte;
        byte readByte2;
        boolean z10;
        boolean z11;
        String str;
        String str2;
        boolean z12 = f8668l;
        if (z12) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.f8655s = ByteOrder.BIG_ENDIAN;
        byte b10 = -1;
        if (bVar.readByte() == -1) {
            if (bVar.readByte() == -40) {
                int i12 = 2;
                int i13 = 2;
                while (true) {
                    if (bVar.readByte() == b10) {
                        int i14 = i13 + 1;
                        byte readByte3 = bVar.readByte();
                        if (z12) {
                            Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                        }
                        int i15 = i14 + 1;
                        if (readByte3 != -39 && readByte3 != -38) {
                            int readUnsignedShort = bVar.readUnsignedShort() - i12;
                            int i16 = i15 + i12;
                            if (z12) {
                                Log.d("ExifInterface", "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")");
                            }
                            if (readUnsignedShort >= 0) {
                                HashMap[] hashMapArr = this.f8686d;
                                if (readByte3 != -31) {
                                    if (readByte3 != -2) {
                                        switch (readByte3) {
                                            default:
                                                switch (readByte3) {
                                                    default:
                                                        switch (readByte3) {
                                                            default:
                                                                switch (readByte3) {
                                                                }
                                                            case -55:
                                                            case -54:
                                                            case -53:
                                                                bVar.a(1);
                                                                HashMap hashMap = hashMapArr[i11];
                                                                if (i11 != 4) {
                                                                    str = "ImageLength";
                                                                } else {
                                                                    str = "ThumbnailImageLength";
                                                                }
                                                                hashMap.put(str, c.b(bVar.readUnsignedShort(), this.f8688f));
                                                                HashMap hashMap2 = hashMapArr[i11];
                                                                if (i11 != 4) {
                                                                    str2 = "ImageWidth";
                                                                } else {
                                                                    str2 = "ThumbnailImageWidth";
                                                                }
                                                                hashMap2.put(str2, c.b(bVar.readUnsignedShort(), this.f8688f));
                                                                readUnsignedShort -= 5;
                                                                break;
                                                        }
                                                    case -59:
                                                    case -58:
                                                    case -57:
                                                        break;
                                                }
                                            case -64:
                                            case -63:
                                            case -62:
                                            case -61:
                                                break;
                                        }
                                        if (readUnsignedShort < 0) {
                                            bVar.a(readUnsignedShort);
                                            i13 = i16 + readUnsignedShort;
                                            i12 = 2;
                                            b10 = -1;
                                        } else {
                                            throw new IOException("Invalid length");
                                        }
                                    } else {
                                        byte[] bArr = new byte[readUnsignedShort];
                                        if (bVar.read(bArr) == readUnsignedShort) {
                                            if (b("UserComment") == null) {
                                                hashMapArr[1].put("UserComment", c.a(new String(bArr, L)));
                                            }
                                        } else {
                                            throw new IOException("Invalid exif");
                                        }
                                    }
                                } else {
                                    byte[] bArr2 = new byte[readUnsignedShort];
                                    bVar.readFully(bArr2);
                                    int i17 = i16 + readUnsignedShort;
                                    byte[] bArr3 = M;
                                    if (bArr3 != null && readUnsignedShort >= bArr3.length) {
                                        for (int i18 = 0; i18 < bArr3.length; i18++) {
                                            if (bArr2[i18] == bArr3[i18]) {
                                            }
                                        }
                                        z10 = true;
                                        if (!z10) {
                                            byte[] copyOfRange = Arrays.copyOfRange(bArr2, bArr3.length, readUnsignedShort);
                                            this.f8690h = i10 + i16 + bArr3.length;
                                            r(i11, copyOfRange);
                                            u(new b(copyOfRange));
                                        } else {
                                            byte[] bArr4 = N;
                                            if (bArr4 != null && readUnsignedShort >= bArr4.length) {
                                                for (int i19 = 0; i19 < bArr4.length; i19++) {
                                                    if (bArr2[i19] == bArr4[i19]) {
                                                    }
                                                }
                                                z11 = true;
                                                if (z11) {
                                                    int length = bArr4.length + i16;
                                                    byte[] copyOfRange2 = Arrays.copyOfRange(bArr2, bArr4.length, readUnsignedShort);
                                                    if (b("Xmp") == null) {
                                                        hashMapArr[0].put("Xmp", new c(length, copyOfRange2, 1, copyOfRange2.length));
                                                    }
                                                }
                                            }
                                            z11 = false;
                                            if (z11) {
                                            }
                                        }
                                        i16 = i17;
                                    }
                                    z10 = false;
                                    if (!z10) {
                                    }
                                    i16 = i17;
                                }
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 0) {
                                }
                            } else {
                                throw new IOException("Invalid length");
                            }
                        }
                    } else {
                        throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
                    }
                }
            } else {
                throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
            }
        } else {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
    }

    public final int f(BufferedInputStream bufferedInputStream) {
        boolean z10;
        boolean z11;
        b bVar;
        b bVar2;
        boolean z12;
        b bVar3;
        b bVar4;
        boolean z13;
        b bVar5;
        b bVar6;
        boolean z14;
        boolean z15;
        boolean z16;
        long j10;
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr2 = f8671o;
            if (i10 < bArr2.length) {
                if (bArr[i10] != bArr2[i10]) {
                    z10 = false;
                    break;
                }
                i10++;
            } else {
                z10 = true;
                break;
            }
        }
        if (z10) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i11 = 0;
        while (true) {
            if (i11 < bytes.length) {
                if (bArr[i11] != bytes[i11]) {
                    z11 = false;
                    break;
                }
                i11++;
            } else {
                z11 = true;
                break;
            }
        }
        if (z11) {
            return 9;
        }
        try {
            bVar2 = new b(bArr);
            try {
                long readInt = bVar2.readInt();
                byte[] bArr3 = new byte[4];
                bVar2.read(bArr3);
                if (Arrays.equals(bArr3, f8672p)) {
                    if (readInt == 1) {
                        readInt = bVar2.readLong();
                        j10 = 16;
                        if (readInt < 16) {
                        }
                    } else {
                        j10 = 8;
                    }
                    long j11 = 5000;
                    if (readInt > j11) {
                        readInt = j11;
                    }
                    long j12 = readInt - j10;
                    if (j12 >= 8) {
                        byte[] bArr4 = new byte[4];
                        boolean z17 = false;
                        boolean z18 = false;
                        for (long j13 = 0; j13 < j12 / 4 && bVar2.read(bArr4) == 4; j13++) {
                            if (j13 != 1) {
                                if (Arrays.equals(bArr4, f8673q)) {
                                    z17 = true;
                                } else if (Arrays.equals(bArr4, f8674r)) {
                                    z18 = true;
                                }
                                if (z17 && z18) {
                                    bVar2.close();
                                    z12 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e10) {
                e = e10;
                try {
                    if (f8668l) {
                        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 e11) {
            e = e11;
            bVar2 = null;
        } catch (Throwable th3) {
            th = th3;
            bVar = null;
            bVar2 = bVar;
            if (bVar2 != null) {
            }
            throw th;
        }
        bVar2.close();
        z12 = false;
        if (z12) {
            return 12;
        }
        try {
            bVar4 = new b(bArr);
            try {
                ByteOrder q10 = q(bVar4);
                this.f8688f = q10;
                bVar4.f8655s = q10;
                short readShort = bVar4.readShort();
                if (readShort != 20306 && readShort != 21330) {
                    z13 = false;
                } else {
                    z13 = true;
                }
                bVar4.close();
            } catch (Exception unused) {
                if (bVar4 != null) {
                    bVar4.close();
                }
                z13 = false;
                if (!z13) {
                }
            } 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 (!z13) {
            return 7;
        }
        try {
            b bVar7 = new b(bArr);
            try {
                ByteOrder q11 = q(bVar7);
                this.f8688f = q11;
                bVar7.f8655s = q11;
                if (bVar7.readShort() == 85) {
                    z14 = true;
                } else {
                    z14 = false;
                }
                bVar7.close();
            } catch (Exception unused3) {
                bVar6 = bVar7;
                if (bVar6 != null) {
                    bVar6.close();
                }
                z14 = false;
                if (!z14) {
                }
            } 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 (!z14) {
            return 10;
        }
        int i12 = 0;
        while (true) {
            byte[] bArr5 = f8677u;
            if (i12 < bArr5.length) {
                if (bArr[i12] != bArr5[i12]) {
                    z15 = false;
                    break;
                }
                i12++;
            } else {
                z15 = true;
                break;
            }
        }
        if (z15) {
            return 13;
        }
        int i13 = 0;
        while (true) {
            byte[] bArr6 = f8681y;
            if (i13 < bArr6.length) {
                if (bArr[i13] != bArr6[i13]) {
                    break;
                }
                i13++;
            } else {
                int i14 = 0;
                while (true) {
                    byte[] bArr7 = f8682z;
                    if (i14 < bArr7.length) {
                        if (bArr[bArr6.length + i14 + 4] != bArr7[i14]) {
                            break;
                        }
                        i14++;
                    } else {
                        z16 = true;
                        break;
                    }
                }
            }
        }
        z16 = false;
        if (!z16) {
            return 0;
        }
        return 14;
    }

    public final void g(f fVar) {
        c cVar;
        c cVar2;
        c cVar3;
        int i10;
        int i11;
        long j10;
        j(fVar);
        HashMap[] hashMapArr = this.f8686d;
        c cVar4 = (c) hashMapArr[1].get("MakerNote");
        if (cVar4 != null) {
            f fVar2 = new f(cVar4.f8661d);
            fVar2.f8655s = this.f8688f;
            byte[] bArr = f8675s;
            byte[] bArr2 = new byte[bArr.length];
            fVar2.readFully(bArr2);
            fVar2.e(0L);
            byte[] bArr3 = f8676t;
            byte[] bArr4 = new byte[bArr3.length];
            fVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                j10 = 8;
            } else {
                j10 = Arrays.equals(bArr4, bArr3) ? 12L : 12L;
                s(fVar2, 6);
                cVar = (c) hashMapArr[7].get("PreviewImageStart");
                cVar2 = (c) hashMapArr[7].get("PreviewImageLength");
                if (cVar != null && cVar2 != null) {
                    hashMapArr[5].put("JPEGInterchangeFormat", cVar);
                    hashMapArr[5].put("JPEGInterchangeFormatLength", cVar2);
                }
                cVar3 = (c) hashMapArr[8].get("AspectFrame");
                if (cVar3 == null) {
                    int[] iArr = (int[]) cVar3.h(this.f8688f);
                    if (iArr != null && iArr.length == 4) {
                        int i12 = iArr[2];
                        int i13 = iArr[0];
                        if (i12 > i13 && (i10 = iArr[3]) > (i11 = iArr[1])) {
                            int i14 = (i12 - i13) + 1;
                            int i15 = (i10 - i11) + 1;
                            if (i14 < i15) {
                                int i16 = i14 + i15;
                                i15 = i16 - i15;
                                i14 = i16 - i15;
                            }
                            c d10 = c.d(i14, this.f8688f);
                            c d11 = c.d(i15, this.f8688f);
                            hashMapArr[0].put("ImageWidth", d10);
                            hashMapArr[0].put("ImageLength", d11);
                            return;
                        }
                        return;
                    }
                    Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
                    return;
                }
                return;
            }
            fVar2.e(j10);
            s(fVar2, 6);
            cVar = (c) hashMapArr[7].get("PreviewImageStart");
            cVar2 = (c) hashMapArr[7].get("PreviewImageLength");
            if (cVar != null) {
                hashMapArr[5].put("JPEGInterchangeFormat", cVar);
                hashMapArr[5].put("JPEGInterchangeFormatLength", cVar2);
            }
            cVar3 = (c) hashMapArr[8].get("AspectFrame");
            if (cVar3 == null) {
            }
        }
    }

    public final void h(b bVar) {
        if (f8668l) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.f8655s = ByteOrder.BIG_ENDIAN;
        byte[] bArr = f8677u;
        bVar.a(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = bVar.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int i11 = i10 + 4;
                    if (i11 == 16 && !Arrays.equals(bArr2, f8679w)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (!Arrays.equals(bArr2, f8680x)) {
                        if (Arrays.equals(bArr2, f8678v)) {
                            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.f8690h = i11;
                                    r(0, bArr3);
                                    x();
                                    u(new b(bArr3));
                                    return;
                                }
                                throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                            }
                            throw new IOException("Failed to read given length for given PNG chunk type: " + com.bumptech.glide.c.b(bArr2));
                        }
                        int i12 = readInt + 4;
                        bVar.a(i12);
                        length = i11 + i12;
                    } else {
                        return;
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void i(b bVar) {
        boolean z10 = f8668l;
        if (z10) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + bVar);
        }
        bVar.a(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        byte[] bArr3 = new byte[4];
        bVar.read(bArr);
        bVar.read(bArr2);
        bVar.read(bArr3);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        int i12 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i11];
        bVar.a(i10 - bVar.f8656t);
        bVar.read(bArr4);
        e(new b(bArr4), i10, 5);
        bVar.a(i12 - bVar.f8656t);
        bVar.f8655s = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (z10) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i13 = 0; i13 < readInt; i13++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == E.f8662a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c d10 = c.d(readShort, this.f8688f);
                c d11 = c.d(readShort2, this.f8688f);
                HashMap[] hashMapArr = this.f8686d;
                hashMapArr[0].put("ImageLength", d10);
                hashMapArr[0].put("ImageWidth", d11);
                if (z10) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.a(readUnsignedShort2);
        }
    }

    public final void j(f fVar) {
        o(fVar);
        s(fVar, 0);
        w(fVar, 0);
        w(fVar, 5);
        w(fVar, 4);
        x();
        if (this.f8685c == 8) {
            HashMap[] hashMapArr = this.f8686d;
            c cVar = (c) hashMapArr[1].get("MakerNote");
            if (cVar != null) {
                f fVar2 = new f(cVar.f8661d);
                fVar2.f8655s = this.f8688f;
                fVar2.a(6);
                s(fVar2, 9);
                c cVar2 = (c) hashMapArr[9].get("ColorSpace");
                if (cVar2 != null) {
                    hashMapArr[1].put("ColorSpace", cVar2);
                }
            }
        }
    }

    public final void k(f fVar) {
        if (f8668l) {
            Log.d("ExifInterface", "getRw2Attributes starting with: " + fVar);
        }
        j(fVar);
        HashMap[] hashMapArr = this.f8686d;
        c cVar = (c) hashMapArr[0].get("JpgFromRaw");
        if (cVar != null) {
            e(new b(cVar.f8661d), (int) cVar.f8660c, 5);
        }
        c cVar2 = (c) hashMapArr[0].get("ISO");
        c cVar3 = (c) hashMapArr[1].get("PhotographicSensitivity");
        if (cVar2 == null || cVar3 != null) {
            return;
        }
        hashMapArr[1].put("PhotographicSensitivity", cVar2);
    }

    public final void l(b bVar) {
        if (f8668l) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.f8655s = ByteOrder.LITTLE_ENDIAN;
        bVar.a(f8681y.length);
        int readInt = bVar.readInt() + 8;
        byte[] bArr = f8682z;
        bVar.a(bArr.length);
        int length = bArr.length + 8;
        while (true) {
            try {
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int readInt2 = bVar.readInt();
                    int i10 = length + 4 + 4;
                    if (Arrays.equals(A, bArr2)) {
                        byte[] bArr3 = new byte[readInt2];
                        if (bVar.read(bArr3) == readInt2) {
                            this.f8690h = i10;
                            r(0, bArr3);
                            u(new b(bArr3));
                            return;
                        }
                        throw new IOException("Failed to read given length for given PNG chunk type: " + com.bumptech.glide.c.b(bArr2));
                    }
                    if (readInt2 % 2 == 1) {
                        readInt2++;
                    }
                    length = i10 + readInt2;
                    if (length == readInt) {
                        return;
                    }
                    if (length <= readInt) {
                        bVar.a(readInt2);
                    } 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 m(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int f10 = cVar.f(this.f8688f);
        int f11 = cVar2.f(this.f8688f);
        if (this.f8685c == 7) {
            f10 += this.f8691i;
        }
        if (f10 > 0 && f11 > 0 && this.f8684b == null && this.f8683a == null) {
            bVar.skip(f10);
            bVar.read(new byte[f11]);
        }
        if (f8668l) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + f10 + ", length: " + f11);
        }
    }

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

    public final void o(b bVar) {
        ByteOrder q10 = q(bVar);
        this.f8688f = q10;
        bVar.f8655s = q10;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i10 = this.f8685c;
        if (i10 != 7 && i10 != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = bVar.readInt();
        if (readInt >= 8) {
            int i11 = readInt - 8;
            if (i11 > 0) {
                bVar.a(i11);
                return;
            }
            return;
        }
        throw new IOException(i0.n("Invalid first Ifd offset: ", readInt));
    }

    public final void p() {
        int i10 = 0;
        while (true) {
            HashMap[] hashMapArr = this.f8686d;
            if (i10 < hashMapArr.length) {
                StringBuilder l10 = a.d.l("The size of tag group[", i10, "]: ");
                l10.append(hashMapArr[i10].size());
                Log.d("ExifInterface", l10.toString());
                for (Map.Entry entry : hashMapArr[i10].entrySet()) {
                    c cVar = (c) entry.getValue();
                    Log.d("ExifInterface", "tagName: " + ((String) entry.getKey()) + ", tagType: " + cVar.toString() + ", tagValue: '" + cVar.g(this.f8688f) + "'");
                }
                i10++;
            } else {
                return;
            }
        }
    }

    public final void r(int i10, byte[] bArr) {
        f fVar = new f(bArr);
        o(fVar);
        s(fVar, i10);
    }

    public final void s(f fVar, int i10) {
        int i11;
        HashMap[] hashMapArr;
        StringBuilder sb2;
        short s5;
        short s10;
        long j10;
        StringBuilder sb3;
        int[] iArr;
        boolean z10;
        long j11;
        boolean z11;
        int i12;
        HashSet hashSet;
        String str;
        int i13;
        int i14;
        String str2;
        long j12;
        HashSet hashSet2;
        int readUnsignedShort;
        long j13;
        HashSet hashSet3;
        StringBuilder sb4;
        String str3;
        Integer valueOf = Integer.valueOf(fVar.f8656t);
        HashSet hashSet4 = this.f8687e;
        hashSet4.add(valueOf);
        short readShort = fVar.readShort();
        String str4 = "ExifInterface";
        boolean z12 = f8668l;
        if (z12) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (readShort <= 0) {
            return;
        }
        short s11 = 0;
        while (true) {
            i11 = 5;
            hashMapArr = this.f8686d;
            if (s11 >= readShort) {
                break;
            }
            int readUnsignedShort2 = fVar.readUnsignedShort();
            int readUnsignedShort3 = fVar.readUnsignedShort();
            int readInt = fVar.readInt();
            long j14 = fVar.f8656t + 4;
            d dVar = (d) H[i10].get(Integer.valueOf(readUnsignedShort2));
            if (z12) {
                Object[] objArr = new Object[5];
                objArr[0] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                if (dVar != null) {
                    str3 = dVar.f8663b;
                } else {
                    str3 = null;
                }
                objArr[2] = str3;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d(str4, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            }
            if (dVar == null) {
                if (z12) {
                    Log.d(str4, "Skip the tag entry since tag number is not defined: " + readUnsignedShort2);
                }
                s5 = readShort;
                s10 = s11;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < C.length) {
                        int i15 = dVar.f8664c;
                        s5 = readShort;
                        if (i15 != 7 && readUnsignedShort3 != 7 && i15 != readUnsignedShort3 && (i12 = dVar.f8665d) != readUnsignedShort3) {
                            s10 = s11;
                            if (((i15 != 4 && i12 != 4) || readUnsignedShort3 != 3) && (((i15 != 9 && i12 != 9) || readUnsignedShort3 != 8) && ((i15 != 12 && i12 != 12) || readUnsignedShort3 != 11))) {
                                z10 = false;
                                if (z10) {
                                    if (z12) {
                                        sb3 = new StringBuilder("Skip the tag entry since data format (");
                                        sb3.append(B[readUnsignedShort3]);
                                        sb3.append(") is unexpected for tag: ");
                                        sb3.append(dVar.f8663b);
                                        j10 = j14;
                                        Log.d(str4, sb3.toString());
                                        j11 = 0;
                                        z11 = false;
                                        if (!z11) {
                                            hashSet2 = hashSet4;
                                            str2 = str4;
                                            j12 = j10;
                                        } else {
                                            if (j11 > 4) {
                                                int readInt2 = fVar.readInt();
                                                if (z12) {
                                                    Log.d(str4, "seek to data offset: " + readInt2);
                                                }
                                                if (this.f8685c == 7) {
                                                    if ("MakerNote".equals(dVar.f8663b)) {
                                                        this.f8691i = readInt2;
                                                    } else if (i10 == 6 && "ThumbnailImage".equals(dVar.f8663b)) {
                                                        this.f8692j = readInt2;
                                                        this.f8693k = readInt;
                                                        c d10 = c.d(6, this.f8688f);
                                                        i13 = readUnsignedShort3;
                                                        i14 = readInt;
                                                        c b10 = c.b(this.f8692j, this.f8688f);
                                                        hashSet = hashSet4;
                                                        str = str4;
                                                        c b11 = c.b(this.f8693k, this.f8688f);
                                                        hashMapArr[4].put("Compression", d10);
                                                        hashMapArr[4].put("JPEGInterchangeFormat", b10);
                                                        hashMapArr[4].put("JPEGInterchangeFormatLength", b11);
                                                        fVar.e(readInt2);
                                                    }
                                                }
                                                hashSet = hashSet4;
                                                str = str4;
                                                i13 = readUnsignedShort3;
                                                i14 = readInt;
                                                fVar.e(readInt2);
                                            } else {
                                                hashSet = hashSet4;
                                                str = str4;
                                                i13 = readUnsignedShort3;
                                                i14 = readInt;
                                            }
                                            Integer num = (Integer) K.get(Integer.valueOf(readUnsignedShort2));
                                            if (z12) {
                                                str2 = str;
                                                Log.d(str2, "nextIfdType: " + num + " byteCount: " + j11);
                                            } else {
                                                str2 = str;
                                            }
                                            if (num != null) {
                                                int i16 = i13;
                                                if (i16 != 3) {
                                                    if (i16 != 4) {
                                                        if (i16 != 8) {
                                                            if (i16 != 9 && i16 != 13) {
                                                                j13 = -1;
                                                            } else {
                                                                readUnsignedShort = fVar.readInt();
                                                            }
                                                        } else {
                                                            readUnsignedShort = fVar.readShort();
                                                        }
                                                    } else {
                                                        j13 = fVar.readInt() & 4294967295L;
                                                    }
                                                    if (z12) {
                                                        Log.d(str2, String.format("Offset: %d, tagName: %s", Long.valueOf(j13), dVar.f8663b));
                                                    }
                                                    if (j13 <= 0) {
                                                        hashSet3 = hashSet;
                                                        if (!hashSet3.contains(Integer.valueOf((int) j13))) {
                                                            fVar.e(j13);
                                                            s(fVar, num.intValue());
                                                        } else if (z12) {
                                                            sb4 = new StringBuilder("Skip jump into the IFD since it has already been read: IfdType ");
                                                            sb4.append(num);
                                                            sb4.append(" (at ");
                                                            sb4.append(j13);
                                                            sb4.append(")");
                                                            Log.d(str2, sb4.toString());
                                                        }
                                                        fVar.e(j10);
                                                        hashSet2 = hashSet3;
                                                    } else {
                                                        hashSet3 = hashSet;
                                                        if (z12) {
                                                            sb4 = new StringBuilder("Skip jump into the IFD since its offset is invalid: ");
                                                            sb4.append(j13);
                                                            Log.d(str2, sb4.toString());
                                                        }
                                                        fVar.e(j10);
                                                        hashSet2 = hashSet3;
                                                    }
                                                } else {
                                                    readUnsignedShort = fVar.readUnsignedShort();
                                                }
                                                j13 = readUnsignedShort;
                                                if (z12) {
                                                }
                                                if (j13 <= 0) {
                                                }
                                            } else {
                                                j12 = j10;
                                                byte[] bArr = new byte[(int) j11];
                                                fVar.readFully(bArr);
                                                hashSet2 = hashSet;
                                                c cVar = new c(fVar.f8656t + this.f8690h, bArr, i13, i14);
                                                hashMapArr[i10].put(dVar.f8663b, cVar);
                                                String str5 = dVar.f8663b;
                                                if ("DNGVersion".equals(str5)) {
                                                    this.f8685c = 3;
                                                }
                                                if ((("Make".equals(str5) || "Model".equals(str5)) && cVar.g(this.f8688f).contains("PENTAX")) || ("Compression".equals(str5) && cVar.f(this.f8688f) == 65535)) {
                                                    this.f8685c = 8;
                                                }
                                                if (fVar.f8656t == j12) {
                                                }
                                            }
                                            s11 = (short) (s10 + 1);
                                            str4 = str2;
                                            hashSet4 = hashSet2;
                                            readShort = s5;
                                        }
                                        fVar.e(j12);
                                        s11 = (short) (s10 + 1);
                                        str4 = str2;
                                        hashSet4 = hashSet2;
                                        readShort = s5;
                                    }
                                } else {
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i15;
                                    }
                                    j10 = j14;
                                    j11 = iArr[readUnsignedShort3] * readInt;
                                    if (j11 >= 0 && j11 <= 2147483647L) {
                                        z11 = true;
                                        if (!z11) {
                                        }
                                        fVar.e(j12);
                                        s11 = (short) (s10 + 1);
                                        str4 = str2;
                                        hashSet4 = hashSet2;
                                        readShort = s5;
                                    } else {
                                        if (z12) {
                                            Log.d(str4, "Skip the tag entry since the number of components is invalid: " + readInt);
                                        }
                                        z11 = false;
                                        if (!z11) {
                                        }
                                        fVar.e(j12);
                                        s11 = (short) (s10 + 1);
                                        str4 = str2;
                                        hashSet4 = hashSet2;
                                        readShort = s5;
                                    }
                                }
                            }
                        } else {
                            s10 = s11;
                        }
                        z10 = true;
                        if (z10) {
                        }
                    }
                }
                s5 = readShort;
                s10 = s11;
                j10 = j14;
                if (z12) {
                    sb3 = new StringBuilder("Skip the tag entry since data format is invalid: ");
                    sb3.append(readUnsignedShort3);
                    Log.d(str4, sb3.toString());
                }
                j11 = 0;
                z11 = false;
                if (!z11) {
                }
                fVar.e(j12);
                s11 = (short) (s10 + 1);
                str4 = str2;
                hashSet4 = hashSet2;
                readShort = s5;
            }
            j10 = j14;
            j11 = 0;
            z11 = false;
            if (!z11) {
            }
            fVar.e(j12);
            s11 = (short) (s10 + 1);
            str4 = str2;
            hashSet4 = hashSet2;
            readShort = s5;
        }
        HashSet hashSet5 = hashSet4;
        String str6 = str4;
        int readInt3 = fVar.readInt();
        if (z12) {
            Log.d(str6, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
        }
        long j15 = readInt3;
        if (j15 > 0) {
            if (!hashSet5.contains(Integer.valueOf(readInt3))) {
                fVar.e(j15);
                if (hashMapArr[4].isEmpty()) {
                    i11 = 4;
                } else if (!hashMapArr[5].isEmpty()) {
                    return;
                }
                s(fVar, i11);
                return;
            } else if (z12) {
                sb2 = new StringBuilder("Stop reading file since re-reading an IFD may cause an infinite loop: ");
            } else {
                return;
            }
        } else if (z12) {
            sb2 = new StringBuilder("Stop reading file since a wrong offset may cause an infinite loop: ");
        } else {
            return;
        }
        sb2.append(readInt3);
        Log.d(str6, sb2.toString());
    }

    public final void t(String str, String str2, int i10) {
        HashMap[] hashMapArr = this.f8686d;
        if (hashMapArr[i10].isEmpty() || hashMapArr[i10].get(str) == null) {
            return;
        }
        HashMap hashMap = hashMapArr[i10];
        hashMap.put(str2, hashMap.get(str));
        hashMapArr[i10].remove(str);
    }

    public final void u(b bVar) {
        boolean z10;
        String str;
        String str2;
        StringBuilder sb2;
        c cVar;
        int f10;
        HashMap hashMap = this.f8686d[4];
        c cVar2 = (c) hashMap.get("Compression");
        if (cVar2 != null) {
            int f11 = cVar2.f(this.f8688f);
            if (f11 != 1) {
                if (f11 != 6) {
                    if (f11 != 7) {
                        return;
                    }
                }
            }
            c cVar3 = (c) hashMap.get("BitsPerSample");
            if (cVar3 != null) {
                int[] iArr = (int[]) cVar3.h(this.f8688f);
                int[] iArr2 = f8669m;
                if (Arrays.equals(iArr2, iArr) || (this.f8685c == 3 && (cVar = (c) hashMap.get("PhotometricInterpretation")) != null && (((f10 = cVar.f(this.f8688f)) == 1 && Arrays.equals(iArr, f8670n)) || (f10 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z10 = true;
                    if (!z10) {
                        c cVar4 = (c) hashMap.get("StripOffsets");
                        c cVar5 = (c) hashMap.get("StripByteCounts");
                        if (cVar4 != null && cVar5 != null) {
                            long[] t3 = com.bumptech.glide.c.t(cVar4.h(this.f8688f));
                            long[] t10 = com.bumptech.glide.c.t(cVar5.h(this.f8688f));
                            if (t3 != null && t3.length != 0) {
                                if (t10 != null && t10.length != 0) {
                                    if (t3.length != t10.length) {
                                        str = "stripOffsets and stripByteCounts should have same length.";
                                    } else {
                                        long j10 = 0;
                                        for (long j11 : t10) {
                                            j10 += j11;
                                        }
                                        byte[] bArr = new byte[(int) j10];
                                        this.f8689g = true;
                                        int i10 = 0;
                                        int i11 = 0;
                                        for (int i12 = 0; i12 < t3.length; i12++) {
                                            int i13 = (int) t3[i12];
                                            int i14 = (int) t10[i12];
                                            if (i12 < t3.length - 1 && i13 + i14 != t3[i12 + 1]) {
                                                this.f8689g = false;
                                            }
                                            int i15 = i13 - i10;
                                            if (i15 < 0) {
                                                str2 = "Invalid strip offset value";
                                            } else {
                                                long j12 = i15;
                                                if (bVar.skip(j12) != j12) {
                                                    sb2 = new StringBuilder("Failed to skip ");
                                                    sb2.append(i15);
                                                } else {
                                                    int i16 = i10 + i15;
                                                    byte[] bArr2 = new byte[i14];
                                                    if (bVar.read(bArr2) != i14) {
                                                        sb2 = new StringBuilder("Failed to read ");
                                                        sb2.append(i14);
                                                    } else {
                                                        i10 = i16 + i14;
                                                        System.arraycopy(bArr2, 0, bArr, i11, i14);
                                                        i11 += i14;
                                                    }
                                                }
                                                sb2.append(" bytes.");
                                                str2 = sb2.toString();
                                            }
                                            Log.d("ExifInterface", str2);
                                            return;
                                        }
                                        if (this.f8689g) {
                                            long j13 = t3[0];
                                            return;
                                        }
                                        return;
                                    }
                                } else {
                                    str = "stripByteCounts should not be null or have zero length.";
                                }
                            } else {
                                str = "stripOffsets should not be null or have zero length.";
                            }
                            Log.w("ExifInterface", str);
                            return;
                        }
                        return;
                    }
                    return;
                }
            }
            if (f8668l) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z10 = false;
            if (!z10) {
            }
        }
        m(bVar, hashMap);
    }

    public final void v(int i10, int i11) {
        String str;
        HashMap[] hashMapArr = this.f8686d;
        boolean isEmpty = hashMapArr[i10].isEmpty();
        boolean z10 = f8668l;
        if (isEmpty || hashMapArr[i11].isEmpty()) {
            if (z10) {
                Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
                return;
            }
            return;
        }
        c cVar = (c) hashMapArr[i10].get("ImageLength");
        c cVar2 = (c) hashMapArr[i10].get("ImageWidth");
        c cVar3 = (c) hashMapArr[i11].get("ImageLength");
        c cVar4 = (c) hashMapArr[i11].get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            if (!z10) {
                return;
            }
            str = "First image does not contain valid size information";
        } else if (cVar3 != null && cVar4 != null) {
            int f10 = cVar.f(this.f8688f);
            int f11 = cVar2.f(this.f8688f);
            int f12 = cVar3.f(this.f8688f);
            int f13 = cVar4.f(this.f8688f);
            if (f10 >= f12 || f11 >= f13) {
                return;
            }
            HashMap hashMap = hashMapArr[i10];
            hashMapArr[i10] = hashMapArr[i11];
            hashMapArr[i11] = hashMap;
            return;
        } else if (!z10) {
            return;
        } else {
            str = "Second image does not contain valid size information";
        }
        Log.d("ExifInterface", str);
    }

    public final void w(f fVar, int i10) {
        StringBuilder sb2;
        String arrays;
        c d10;
        c d11;
        HashMap[] hashMapArr = this.f8686d;
        c cVar = (c) hashMapArr[i10].get("DefaultCropSize");
        c cVar2 = (c) hashMapArr[i10].get("SensorTopBorder");
        c cVar3 = (c) hashMapArr[i10].get("SensorLeftBorder");
        c cVar4 = (c) hashMapArr[i10].get("SensorBottomBorder");
        c cVar5 = (c) hashMapArr[i10].get("SensorRightBorder");
        if (cVar != null) {
            if (cVar.f8658a == 5) {
                e[] eVarArr = (e[]) cVar.h(this.f8688f);
                if (eVarArr != null && eVarArr.length == 2) {
                    d10 = c.c(eVarArr[0], this.f8688f);
                    d11 = c.c(eVarArr[1], this.f8688f);
                    hashMapArr[i10].put("ImageWidth", d10);
                    hashMapArr[i10].put("ImageLength", d11);
                    return;
                }
                sb2 = new StringBuilder("Invalid crop size values. cropSize=");
                arrays = Arrays.toString(eVarArr);
                sb2.append(arrays);
                Log.w("ExifInterface", sb2.toString());
            }
            int[] iArr = (int[]) cVar.h(this.f8688f);
            if (iArr != null && iArr.length == 2) {
                d10 = c.d(iArr[0], this.f8688f);
                d11 = c.d(iArr[1], this.f8688f);
                hashMapArr[i10].put("ImageWidth", d10);
                hashMapArr[i10].put("ImageLength", d11);
                return;
            }
            sb2 = new StringBuilder("Invalid crop size values. cropSize=");
            arrays = Arrays.toString(iArr);
            sb2.append(arrays);
            Log.w("ExifInterface", sb2.toString());
        } else if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) {
            int f10 = cVar2.f(this.f8688f);
            int f11 = cVar4.f(this.f8688f);
            int f12 = cVar5.f(this.f8688f);
            int f13 = cVar3.f(this.f8688f);
            if (f11 > f10 && f12 > f13) {
                c d12 = c.d(f11 - f10, this.f8688f);
                c d13 = c.d(f12 - f13, this.f8688f);
                hashMapArr[i10].put("ImageLength", d12);
                hashMapArr[i10].put("ImageWidth", d13);
            }
        } else {
            c cVar6 = (c) hashMapArr[i10].get("ImageLength");
            c cVar7 = (c) hashMapArr[i10].get("ImageWidth");
            if (cVar6 == null || cVar7 == null) {
                c cVar8 = (c) hashMapArr[i10].get("JPEGInterchangeFormat");
                c cVar9 = (c) hashMapArr[i10].get("JPEGInterchangeFormatLength");
                if (cVar8 != null && cVar9 != null) {
                    int f14 = cVar8.f(this.f8688f);
                    int f15 = cVar8.f(this.f8688f);
                    fVar.e(f14);
                    byte[] bArr = new byte[f15];
                    fVar.read(bArr);
                    e(new b(bArr), f14, i10);
                }
            }
        }
    }

    public final void x() {
        v(0, 5);
        v(0, 4);
        v(5, 4);
        HashMap[] hashMapArr = this.f8686d;
        c cVar = (c) hashMapArr[1].get("PixelXDimension");
        c cVar2 = (c) hashMapArr[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            hashMapArr[0].put("ImageWidth", cVar);
            hashMapArr[0].put("ImageLength", cVar2);
        }
        if (hashMapArr[4].isEmpty() && n(hashMapArr[5])) {
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap();
        }
        if (!n(hashMapArr[4])) {
            Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
        }
        t("ThumbnailOrientation", "Orientation", 0);
        t("ThumbnailImageLength", "ImageLength", 0);
        t("ThumbnailImageWidth", "ImageWidth", 0);
        t("ThumbnailOrientation", "Orientation", 5);
        t("ThumbnailImageLength", "ImageLength", 5);
        t("ThumbnailImageWidth", "ImageWidth", 5);
        t("Orientation", "ThumbnailOrientation", 4);
        t("ImageLength", "ThumbnailImageLength", 4);
        t("ImageWidth", "ThumbnailImageWidth", 4);
    }
}