package V1;

import Z0.o;
import android.content.res.AssetManager;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.OsConstants;
import android.util.Log;
import androidx.media3.extractor.ts.TsExtractor;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ColorExtractionConstants;
import e4.C;
import j$.util.DesugarTimeZone;
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.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.CRC32;

/* JADX INFO: loaded from: classes.dex */
public final class g {

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public static final String[] f7210D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public static final int[] f7211E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public static final byte[] f7212F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public static final d f7213G;

    /* JADX INFO: renamed from: H, reason: collision with root package name */
    public static final d[][] f7214H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public static final d[] f7215I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public static final HashMap[] f7216J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public static final HashMap[] f7217K;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public static final HashSet f7218L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public static final HashMap f7219M;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public static final Charset f7220N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public static final byte[] f7221O;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public static final byte[] f7222P;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final FileDescriptor f7237a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final AssetManager.AssetInputStream f7238b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f7239c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final HashMap[] f7240d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final HashSet f7241e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public ByteOrder f7242f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f7243g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f7244h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f7245i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f7246j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f7247k;
    public static final boolean l = Log.isLoggable("ExifInterface", 3);

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final List f7223m = Arrays.asList(1, 6, 3, 8);

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public static final List f7224n = Arrays.asList(2, 7, 4, 5);

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public static final int[] f7225o = {8, 8, 8};

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public static final int[] f7226p = {8};

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public static final byte[] f7227q = {-1, -40, -1};

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public static final byte[] f7228r = {102, 116, 121, 112};

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static final byte[] f7229s = {109, 105, 102, 49};

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public static final byte[] f7230t = {104, 101, 105, 99};

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public static final byte[] f7231u = {79, 76, 89, 77, 80, 0};

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final byte[] f7232v = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final byte[] f7233w = {-119, 80, 78, 71, 13, 10, 26, 10};

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final byte[] f7234x = {101, 88, 73, 102};

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final byte[] f7235y = {73, 72, 68, 82};

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final byte[] f7236z = {73, 69, 78, 68};

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final byte[] f7207A = {82, 73, 70, 70};

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public static final byte[] f7208B = {87, 69, 66, 80};

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public static final byte[] f7209C = {69, 88, 73, 70};

    static {
        "VP8X".getBytes(Charset.defaultCharset());
        "VP8L".getBytes(Charset.defaultCharset());
        "VP8 ".getBytes(Charset.defaultCharset());
        "ANIM".getBytes(Charset.defaultCharset());
        "ANMF".getBytes(Charset.defaultCharset());
        f7210D = new String[]{"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
        f7211E = new int[]{0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
        f7212F = new byte[]{65, 83, 67, 73, 73, 0, 0, 0};
        d[] dVarArr = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d(256, 3, 4, "ImageWidth"), new d(TsExtractor.TS_STREAM_TYPE_AIT, 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", ColorExtractionConstants.MAXIMUM_BRIGHTNESS_THRESHOLD, 1)};
        d[] dVarArr2 = {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[] dVarArr3 = {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[] dVarArr4 = {new d("InteroperabilityIndex", 1, 2)};
        d[] dVarArr5 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d(256, 3, 4, "ThumbnailImageWidth"), new d(TsExtractor.TS_STREAM_TYPE_AIT, 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("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("DNGVersion", 50706, 1), new d(50720, 3, 4, "DefaultCropSize")};
        f7213G = new d("StripOffsets", 273, 3);
        f7214H = new d[][]{dVarArr, dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr, new d[]{new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)}, new d[]{new d("PreviewImageStart", TsExtractor.TS_STREAM_TYPE_AIT, 4), new d("PreviewImageLength", 258, 4)}, new d[]{new d("AspectFrame", 4371, 3)}, new d[]{new d("ColorSpace", 55, 3)}};
        f7215I = 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)};
        f7216J = new HashMap[10];
        f7217K = new HashMap[10];
        f7218L = new HashSet(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        f7219M = new HashMap();
        Charset charsetForName = Charset.forName("US-ASCII");
        f7220N = charsetForName;
        f7221O = "Exif\u0000\u0000".getBytes(charsetForName);
        f7222P = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(charsetForName);
        Locale locale = Locale.US;
        new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale).setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        int i6 = 0;
        while (true) {
            d[][] dVarArr6 = f7214H;
            if (i6 >= dVarArr6.length) {
                HashMap map = f7219M;
                d[] dVarArr7 = f7215I;
                map.put(Integer.valueOf(dVarArr7[0].f7201a), 5);
                map.put(Integer.valueOf(dVarArr7[1].f7201a), 1);
                map.put(Integer.valueOf(dVarArr7[2].f7201a), 2);
                map.put(Integer.valueOf(dVarArr7[3].f7201a), 3);
                map.put(Integer.valueOf(dVarArr7[4].f7201a), 7);
                map.put(Integer.valueOf(dVarArr7[5].f7201a), 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;
            }
            f7216J[i6] = new HashMap();
            f7217K[i6] = new HashMap();
            for (d dVar : dVarArr6[i6]) {
                f7216J[i6].put(Integer.valueOf(dVar.f7201a), dVar);
                f7217K[i6].put(dVar.f7202b, dVar);
            }
            i6++;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:53:0x00d8 A[Catch: all -> 0x005e, TRY_ENTER, TRY_LEAVE, TryCatch #3 {all -> 0x005e, blocks: (B:14:0x004f, B:16:0x0052, B:23:0x0067, B:29:0x0084, B:31:0x008f, B:39:0x00a5, B:34:0x0096, B:37:0x009e, B:38:0x00a2, B:40:0x00af, B:42:0x00b8, B:44:0x00be, B:46:0x00c4, B:48:0x00ca, B:53:0x00d8), top: B:65:0x004f }] */
    /* JADX WARN: Removed duplicated region for block: B:68:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public g(InputStream inputStream) throws IOException {
        d[][] dVarArr = f7214H;
        this.f7240d = new HashMap[dVarArr.length];
        this.f7241e = new HashSet(dVarArr.length);
        this.f7242f = ByteOrder.BIG_ENDIAN;
        boolean z6 = inputStream instanceof AssetManager.AssetInputStream;
        boolean z7 = l;
        if (z6) {
            this.f7238b = (AssetManager.AssetInputStream) inputStream;
            this.f7237a = null;
        } else if (inputStream instanceof FileInputStream) {
            FileInputStream fileInputStream = (FileInputStream) inputStream;
            try {
                h.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                this.f7238b = null;
                this.f7237a = fileInputStream.getFD();
            } catch (Exception unused) {
                if (z7) {
                    Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                }
                this.f7238b = null;
                this.f7237a = null;
            }
        } else {
            this.f7238b = null;
            this.f7237a = null;
        }
        for (int i6 = 0; i6 < dVarArr.length; i6++) {
            try {
                try {
                    this.f7240d[i6] = new HashMap();
                } catch (Throwable th) {
                    a();
                    if (z7) {
                        p();
                    }
                    throw th;
                }
            } catch (IOException e6) {
                e = e6;
                if (z7) {
                    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.", e);
                }
                a();
                if (!z7) {
                    return;
                }
            } catch (UnsupportedOperationException e7) {
                e = e7;
                if (z7) {
                }
                a();
                if (!z7) {
                }
            }
        }
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
        int iF = f(bufferedInputStream);
        this.f7239c = iF;
        if (iF == 4 || iF == 9 || iF == 13 || iF == 14) {
            b bVar = new b(bufferedInputStream);
            int i7 = this.f7239c;
            if (i7 == 4) {
                e(bVar, 0, 0);
            } else if (i7 == 13) {
                h(bVar);
            } else if (i7 == 9) {
                i(bVar);
            } else if (i7 == 14) {
                l(bVar);
            }
        } else {
            f fVar = new f(bufferedInputStream);
            int i8 = this.f7239c;
            if (i8 == 12) {
                d(fVar);
            } else if (i8 == 7) {
                g(fVar);
            } else if (i8 == 10) {
                k(fVar);
            } else {
                j(fVar);
            }
            fVar.b(this.f7244h);
            u(fVar);
        }
        a();
        if (!z7) {
            return;
        }
        p();
    }

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

    public final void a() {
        String strB = b("DateTimeOriginal");
        HashMap[] mapArr = this.f7240d;
        if (strB != null && b("DateTime") == null) {
            HashMap map = mapArr[0];
            byte[] bytes = strB.concat("\u0000").getBytes(f7220N);
            map.put("DateTime", new c(bytes, 2, bytes.length));
        }
        if (b("ImageWidth") == null) {
            mapArr[0].put("ImageWidth", c.a(0L, this.f7242f));
        }
        if (b("ImageLength") == null) {
            mapArr[0].put("ImageLength", c.a(0L, this.f7242f));
        }
        if (b("Orientation") == null) {
            mapArr[0].put("Orientation", c.a(0L, this.f7242f));
        }
        if (b("LightSource") == null) {
            mapArr[1].put("LightSource", c.a(0L, this.f7242f));
        }
    }

    public final String b(String str) {
        c cVarC = c(str);
        if (cVarC != null) {
            if (!f7218L.contains(str)) {
                return cVarC.f(this.f7242f);
            }
            if (str.equals("GPSTimeStamp")) {
                int i6 = cVarC.f7197a;
                if (i6 != 5 && i6 != 10) {
                    Log.w("ExifInterface", "GPS Timestamp format is not rational. format=" + i6);
                    return null;
                }
                e[] eVarArr = (e[]) cVarC.g(this.f7242f);
                if (eVarArr == null || eVarArr.length != 3) {
                    Log.w("ExifInterface", "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr));
                    return null;
                }
                e eVar = eVarArr[0];
                Integer numValueOf = Integer.valueOf((int) (eVar.f7205a / eVar.f7206b));
                e eVar2 = eVarArr[1];
                Integer numValueOf2 = Integer.valueOf((int) (eVar2.f7205a / eVar2.f7206b));
                e eVar3 = eVarArr[2];
                return String.format("%02d:%02d:%02d", numValueOf, numValueOf2, Integer.valueOf((int) (eVar3.f7205a / eVar3.f7206b)));
            }
            try {
                return Double.toString(cVarC.d(this.f7242f));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

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

    public final void d(f fVar) throws IOException {
        String strExtractMetadata;
        String strExtractMetadata2;
        String strExtractMetadata3;
        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 strExtractMetadata4 = mediaMetadataRetriever.extractMetadata(33);
                String strExtractMetadata5 = mediaMetadataRetriever.extractMetadata(34);
                String strExtractMetadata6 = mediaMetadataRetriever.extractMetadata(26);
                String strExtractMetadata7 = mediaMetadataRetriever.extractMetadata(17);
                if ("yes".equals(strExtractMetadata6)) {
                    strExtractMetadata = mediaMetadataRetriever.extractMetadata(29);
                    strExtractMetadata2 = mediaMetadataRetriever.extractMetadata(30);
                    strExtractMetadata3 = mediaMetadataRetriever.extractMetadata(31);
                } else if ("yes".equals(strExtractMetadata7)) {
                    strExtractMetadata = mediaMetadataRetriever.extractMetadata(18);
                    strExtractMetadata2 = mediaMetadataRetriever.extractMetadata(19);
                    strExtractMetadata3 = mediaMetadataRetriever.extractMetadata(24);
                } else {
                    strExtractMetadata = null;
                    strExtractMetadata2 = null;
                    strExtractMetadata3 = null;
                }
                HashMap[] mapArr = this.f7240d;
                if (strExtractMetadata != null) {
                    mapArr[0].put("ImageWidth", c.c(Integer.parseInt(strExtractMetadata), this.f7242f));
                }
                if (strExtractMetadata2 != null) {
                    mapArr[0].put("ImageLength", c.c(Integer.parseInt(strExtractMetadata2), this.f7242f));
                }
                if (strExtractMetadata3 != null) {
                    int i6 = Integer.parseInt(strExtractMetadata3);
                    mapArr[0].put("Orientation", c.c(i6 != 90 ? i6 != 180 ? i6 != 270 ? 1 : 8 : 3 : 6, this.f7242f));
                }
                if (strExtractMetadata4 != null && strExtractMetadata5 != null) {
                    int i7 = Integer.parseInt(strExtractMetadata4);
                    int i8 = Integer.parseInt(strExtractMetadata5);
                    if (i8 <= 6) {
                        throw new IOException("Invalid exif length");
                    }
                    fVar.b(i7);
                    byte[] bArr = new byte[6];
                    fVar.readFully(bArr);
                    int i9 = i7 + 6;
                    int i10 = i8 - 6;
                    if (!Arrays.equals(bArr, f7221O)) {
                        throw new IOException("Invalid identifier");
                    }
                    byte[] bArr2 = new byte[i10];
                    fVar.readFully(bArr2);
                    this.f7244h = i9;
                    r(bArr2, 0);
                }
                if (l) {
                    Log.d("ExifInterface", "Heif meta: " + strExtractMetadata + "x" + strExtractMetadata2 + ", rotation " + strExtractMetadata3);
                }
                mediaMetadataRetriever.release();
            } catch (RuntimeException unused) {
                throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported.");
            }
        } catch (Throwable th) {
            mediaMetadataRetriever.release();
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:67:0x0134  */
    /* JADX WARN: Removed duplicated region for block: B:98:0x013e A[SYNTHETIC] */
    /*  JADX ERROR: UnsupportedOperationException in pass: RegionMakerVisitor
        java.lang.UnsupportedOperationException
        	at java.base/java.util.Collections$UnmodifiableCollection.add(Collections.java:1092)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker$1.leaveRegion(SwitchRegionMaker.java:390)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:70)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverse(DepthRegionTraversal.java:23)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.insertBreaksForCase(SwitchRegionMaker.java:370)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.insertBreaks(SwitchRegionMaker.java:85)
        	at jadx.core.dex.visitors.regions.PostProcessRegions.leaveRegion(PostProcessRegions.java:33)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:70)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.lambda$traverseInternal$0(DepthRegionTraversal.java:68)
        	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseInternal(DepthRegionTraversal.java:68)
        	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverse(DepthRegionTraversal.java:19)
        	at jadx.core.dex.visitors.regions.PostProcessRegions.process(PostProcessRegions.java:23)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:31)
        */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void e(V1.b r23, int r24, int r25) throws java.io.IOException {
        /*
            Method dump skipped, instruction units count: 528
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: V1.g.e(V1.b, int, int):void");
    }

    /* JADX WARN: Can't wrap try/catch for region: R(12:169|12|(4:164|13|150|14)|(16:17|(2:19|20)(1:28)|23|29|(1:31)|32|(4:152|35|(7:154|39|40|(3:43|(1:45)(2:46|(1:48))|(1:179)(3:177|51|52))(1:180)|53|36|37)|176)|34|160|65|162|66|67|(1:73)(1:72)|74|(1:87)(8:156|89|158|90|91|(1:93)(1:94)|95|(1:107)(3:109|(2:110|(2:112|(2:170|114)(1:115))(2:171|116))|(1:118)(4:120|(2:121|(2:123|(1:173)(1:126))(3:172|127|(2:128|(2:130|(1:175)(1:133))(2:174|134))))|125|(1:136)(1:138)))))|16|160|65|162|66|67|(3:69|73|74)(0)|(0)(0)) */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x0061, code lost:
    
        if (r9 < 16) goto L16;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x00ef, code lost:
    
        r0 = th;
     */
    /* JADX WARN: Code restructure failed: missing block: B:76:0x00f0, code lost:
    
        r6 = r2;
     */
    /* JADX WARN: Code restructure failed: missing block: B:77:0x00f2, code lost:
    
        r0 = th;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x00f4, code lost:
    
        r2 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:80:0x00f6, code lost:
    
        if (r6 != null) goto L81;
     */
    /* JADX WARN: Code restructure failed: missing block: B:81:0x00f8, code lost:
    
        r6.close();
     */
    /* JADX WARN: Code restructure failed: missing block: B:82:0x00fb, code lost:
    
        throw r0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x00fc, code lost:
    
        if (r2 != null) goto L84;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:0x00fe, code lost:
    
        r2.close();
     */
    /* JADX WARN: Code restructure failed: missing block: B:85:0x0101, code lost:
    
        r0 = r18;
     */
    /* JADX WARN: Removed duplicated region for block: B:156:0x0107 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:69:0x00e2  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x00ea  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x0105 A[RETURN] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int f(BufferedInputStream bufferedInputStream) throws Throwable {
        int i6;
        b bVar;
        int i7;
        int i8;
        int i9;
        int i10;
        b bVar2;
        long j4;
        byte[] bArr;
        long j6;
        bufferedInputStream.mark(5000);
        byte[] bArr2 = new byte[5000];
        bufferedInputStream.read(bArr2);
        bufferedInputStream.reset();
        int i11 = 0;
        while (true) {
            byte[] bArr3 = f7227q;
            if (i11 >= bArr3.length) {
                return 4;
            }
            if (bArr2[i11] != bArr3[i11]) {
                byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
                for (int i12 = 0; i12 < bytes.length; i12++) {
                    if (bArr2[i12] != bytes[i12]) {
                        b bVar3 = null;
                        try {
                            bVar = new b(bArr2);
                            try {
                                try {
                                    j4 = bVar.readInt();
                                    bArr = new byte[4];
                                    bVar.readFully(bArr);
                                } catch (Exception e6) {
                                    e = e6;
                                    i6 = 0;
                                }
                            } catch (Throwable th) {
                                th = th;
                                bVar3 = bVar;
                                if (bVar3 != null) {
                                    bVar3.close();
                                }
                                throw th;
                            }
                        } catch (Exception e7) {
                            e = e7;
                            i6 = 0;
                            bVar = null;
                        } catch (Throwable th2) {
                            th = th2;
                        }
                        if (Arrays.equals(bArr, f7228r)) {
                            if (j4 == 1) {
                                j4 = bVar.readLong();
                                j6 = 16;
                            } else {
                                j6 = 8;
                            }
                            i6 = 0;
                            long j7 = 5000;
                            if (j4 > j7) {
                                j4 = j7;
                            }
                            long j8 = j4 - j6;
                            if (j8 >= 8) {
                                try {
                                    byte[] bArr4 = new byte[4];
                                    boolean z6 = false;
                                    boolean z7 = false;
                                    for (long j9 = 0; j9 < j8 / 4; j9++) {
                                        try {
                                            bVar.readFully(bArr4);
                                            if (j9 != 1) {
                                                if (Arrays.equals(bArr4, f7229s)) {
                                                    z6 = true;
                                                } else if (Arrays.equals(bArr4, f7230t)) {
                                                    z7 = true;
                                                }
                                                if (z6 && z7) {
                                                    bVar.close();
                                                    return 12;
                                                }
                                            }
                                        } catch (EOFException unused) {
                                        }
                                    }
                                } catch (Exception e8) {
                                    e = e8;
                                    if (l) {
                                        Log.d("ExifInterface", "Exception parsing HEIF file type box.", e);
                                    }
                                    if (bVar != null) {
                                    }
                                    b bVar4 = new b(bArr2);
                                    ByteOrder byteOrderQ = q(bVar4);
                                    this.f7242f = byteOrderQ;
                                    bVar4.f7194c = byteOrderQ;
                                    short s6 = bVar4.readShort();
                                    if (s6 == 20306) {
                                    }
                                    if (i7 != 0) {
                                    }
                                }
                            }
                            bVar.close();
                            b bVar42 = new b(bArr2);
                            ByteOrder byteOrderQ2 = q(bVar42);
                            this.f7242f = byteOrderQ2;
                            bVar42.f7194c = byteOrderQ2;
                            short s62 = bVar42.readShort();
                            i7 = (s62 == 20306 || s62 == 21330) ? 1 : i6;
                            bVar42.close();
                            if (i7 != 0) {
                                return 7;
                            }
                            try {
                                bVar2 = new b(bArr2);
                            } catch (Exception unused2) {
                            } catch (Throwable th3) {
                                th = th3;
                            }
                            try {
                                ByteOrder byteOrderQ3 = q(bVar2);
                                this.f7242f = byteOrderQ3;
                                bVar2.f7194c = byteOrderQ3;
                                i8 = bVar2.readShort() == 85 ? 1 : i6;
                                bVar2.close();
                            } catch (Exception unused3) {
                                bVar3 = bVar2;
                                if (bVar3 != null) {
                                    bVar3.close();
                                }
                                i8 = i6;
                            } catch (Throwable th4) {
                                th = th4;
                                bVar3 = bVar2;
                                if (bVar3 != null) {
                                    bVar3.close();
                                }
                                throw th;
                            }
                            if (i8 != 0) {
                                return 10;
                            }
                            int i13 = i6;
                            while (true) {
                                byte[] bArr5 = f7233w;
                                if (i13 >= bArr5.length) {
                                    i9 = 1;
                                    break;
                                }
                                if (bArr2[i13] != bArr5[i13]) {
                                    i9 = i6;
                                    break;
                                }
                                i13++;
                            }
                            if (i9 != 0) {
                                return 13;
                            }
                            int i14 = i6;
                            while (true) {
                                byte[] bArr6 = f7207A;
                                if (i14 >= bArr6.length) {
                                    int i15 = i6;
                                    while (true) {
                                        byte[] bArr7 = f7208B;
                                        if (i15 >= bArr7.length) {
                                            i10 = 1;
                                            break;
                                        }
                                        if (bArr2[bArr6.length + i15 + 4] != bArr7[i15]) {
                                            break;
                                        }
                                        i15++;
                                    }
                                } else {
                                    if (bArr2[i14] != bArr6[i14]) {
                                        break;
                                    }
                                    i14++;
                                }
                            }
                            i10 = i6;
                            if (i10 != 0) {
                                return 14;
                            }
                            return i6;
                        }
                        bVar.close();
                        i6 = 0;
                        b bVar422 = new b(bArr2);
                        ByteOrder byteOrderQ22 = q(bVar422);
                        this.f7242f = byteOrderQ22;
                        bVar422.f7194c = byteOrderQ22;
                        short s622 = bVar422.readShort();
                        if (s622 == 20306) {
                            bVar422.close();
                        }
                        if (i7 != 0) {
                        }
                    }
                }
                return 9;
            }
            i11++;
        }
    }

    public final void g(f fVar) throws IOException {
        int i6;
        int i7;
        j(fVar);
        HashMap[] mapArr = this.f7240d;
        c cVar = (c) mapArr[1].get("MakerNote");
        if (cVar != null) {
            f fVar2 = new f(cVar.f7200d);
            fVar2.f7194c = this.f7242f;
            byte[] bArr = f7231u;
            byte[] bArr2 = new byte[bArr.length];
            fVar2.readFully(bArr2);
            fVar2.b(0L);
            byte[] bArr3 = f7232v;
            byte[] bArr4 = new byte[bArr3.length];
            fVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                fVar2.b(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                fVar2.b(12L);
            }
            s(fVar2, 6);
            c cVar2 = (c) mapArr[7].get("PreviewImageStart");
            c cVar3 = (c) mapArr[7].get("PreviewImageLength");
            if (cVar2 != null && cVar3 != null) {
                mapArr[5].put("JPEGInterchangeFormat", cVar2);
                mapArr[5].put("JPEGInterchangeFormatLength", cVar3);
            }
            c cVar4 = (c) mapArr[8].get("AspectFrame");
            if (cVar4 != null) {
                int[] iArr = (int[]) cVar4.g(this.f7242f);
                if (iArr == null || iArr.length != 4) {
                    Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
                    return;
                }
                int i8 = iArr[2];
                int i9 = iArr[0];
                if (i8 <= i9 || (i6 = iArr[3]) <= (i7 = iArr[1])) {
                    return;
                }
                int i10 = (i8 - i9) + 1;
                int i11 = (i6 - i7) + 1;
                if (i10 < i11) {
                    int i12 = i10 + i11;
                    i11 = i12 - i11;
                    i10 = i12 - i11;
                }
                c cVarC = c.c(i10, this.f7242f);
                c cVarC2 = c.c(i11, this.f7242f);
                mapArr[0].put("ImageWidth", cVarC);
                mapArr[0].put("ImageLength", cVarC2);
            }
        }
    }

    public final void h(b bVar) throws IOException {
        if (l) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.f7194c = ByteOrder.BIG_ENDIAN;
        byte[] bArr = f7233w;
        bVar.a(bArr.length);
        int length = bArr.length;
        while (true) {
            try {
                int i6 = bVar.readInt();
                byte[] bArr2 = new byte[4];
                bVar.readFully(bArr2);
                int i7 = length + 8;
                if (i7 == 16 && !Arrays.equals(bArr2, f7235y)) {
                    throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                }
                if (Arrays.equals(bArr2, f7236z)) {
                    return;
                }
                if (Arrays.equals(bArr2, f7234x)) {
                    byte[] bArr3 = new byte[i6];
                    bVar.readFully(bArr3);
                    int i8 = bVar.readInt();
                    CRC32 crc32 = new CRC32();
                    crc32.update(bArr2);
                    crc32.update(bArr3);
                    if (((int) crc32.getValue()) == i8) {
                        this.f7244h = i7;
                        r(bArr3, 0);
                        x();
                        u(new b(bArr3));
                        return;
                    }
                    throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + i8 + ", calculated CRC value: " + crc32.getValue());
                }
                int i9 = i6 + 4;
                bVar.a(i9);
                length = i7 + i9;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void i(b bVar) throws IOException {
        boolean z6 = l;
        if (z6) {
            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.readFully(bArr);
        bVar.readFully(bArr2);
        bVar.readFully(bArr3);
        int i6 = ByteBuffer.wrap(bArr).getInt();
        int i7 = ByteBuffer.wrap(bArr2).getInt();
        int i8 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i7];
        bVar.a(i6 - bVar.f7193b);
        bVar.readFully(bArr4);
        e(new b(bArr4), i6, 5);
        bVar.a(i8 - bVar.f7193b);
        bVar.f7194c = ByteOrder.BIG_ENDIAN;
        int i9 = bVar.readInt();
        if (z6) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + i9);
        }
        for (int i10 = 0; i10 < i9; i10++) {
            int unsignedShort = bVar.readUnsignedShort();
            int unsignedShort2 = bVar.readUnsignedShort();
            if (unsignedShort == f7213G.f7201a) {
                short s6 = bVar.readShort();
                short s7 = bVar.readShort();
                c cVarC = c.c(s6, this.f7242f);
                c cVarC2 = c.c(s7, this.f7242f);
                HashMap[] mapArr = this.f7240d;
                mapArr[0].put("ImageLength", cVarC);
                mapArr[0].put("ImageWidth", cVarC2);
                if (z6) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) s6) + ", width: " + ((int) s7));
                    return;
                }
                return;
            }
            bVar.a(unsignedShort2);
        }
    }

    public final void j(f fVar) throws IOException {
        o(fVar);
        s(fVar, 0);
        w(fVar, 0);
        w(fVar, 5);
        w(fVar, 4);
        x();
        if (this.f7239c == 8) {
            HashMap[] mapArr = this.f7240d;
            c cVar = (c) mapArr[1].get("MakerNote");
            if (cVar != null) {
                f fVar2 = new f(cVar.f7200d);
                fVar2.f7194c = this.f7242f;
                fVar2.a(6);
                s(fVar2, 9);
                c cVar2 = (c) mapArr[9].get("ColorSpace");
                if (cVar2 != null) {
                    mapArr[1].put("ColorSpace", cVar2);
                }
            }
        }
    }

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

    public final void l(b bVar) throws IOException {
        if (l) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.f7194c = ByteOrder.LITTLE_ENDIAN;
        bVar.a(f7207A.length);
        int i6 = bVar.readInt() + 8;
        byte[] bArr = f7208B;
        bVar.a(bArr.length);
        int length = bArr.length + 8;
        while (true) {
            try {
                byte[] bArr2 = new byte[4];
                bVar.readFully(bArr2);
                int i7 = bVar.readInt();
                int i8 = length + 8;
                if (Arrays.equals(f7209C, bArr2)) {
                    byte[] bArr3 = new byte[i7];
                    bVar.readFully(bArr3);
                    this.f7244h = i8;
                    r(bArr3, 0);
                    u(new b(bArr3));
                    return;
                }
                if (i7 % 2 == 1) {
                    i7++;
                }
                length = i8 + i7;
                if (length == i6) {
                    return;
                }
                if (length > i6) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                bVar.a(i7);
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void m(b bVar, HashMap map) throws IOException {
        c cVar = (c) map.get("JPEGInterchangeFormat");
        c cVar2 = (c) map.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int iE = cVar.e(this.f7242f);
        int iE2 = cVar2.e(this.f7242f);
        if (this.f7239c == 7) {
            iE += this.f7245i;
        }
        if (iE > 0 && iE2 > 0 && this.f7238b == null && this.f7237a == null) {
            bVar.a(iE);
            bVar.readFully(new byte[iE2]);
        }
        if (l) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + iE + ", length: " + iE2);
        }
    }

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

    public final void o(f fVar) throws IOException {
        ByteOrder byteOrderQ = q(fVar);
        this.f7242f = byteOrderQ;
        fVar.f7194c = byteOrderQ;
        int unsignedShort = fVar.readUnsignedShort();
        int i6 = this.f7239c;
        if (i6 != 7 && i6 != 10 && unsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(unsignedShort));
        }
        int i7 = fVar.readInt();
        if (i7 < 8) {
            throw new IOException(o.l("Invalid first Ifd offset: ", i7));
        }
        int i8 = i7 - 8;
        if (i8 > 0) {
            fVar.a(i8);
        }
    }

    public final void p() {
        int i6 = 0;
        while (true) {
            HashMap[] mapArr = this.f7240d;
            if (i6 >= mapArr.length) {
                return;
            }
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "The size of tag group[", "]: ");
            sbR.append(mapArr[i6].size());
            Log.d("ExifInterface", sbR.toString());
            for (Map.Entry entry : mapArr[i6].entrySet()) {
                c cVar = (c) entry.getValue();
                Log.d("ExifInterface", "tagName: " + ((String) entry.getKey()) + ", tagType: " + cVar.toString() + ", tagValue: '" + cVar.f(this.f7242f) + "'");
            }
            i6++;
        }
    }

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

    /* JADX WARN: Removed duplicated region for block: B:112:0x022f  */
    /* JADX WARN: Removed duplicated region for block: B:119:0x0253  */
    /* JADX WARN: Removed duplicated region for block: B:126:0x028f  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0148  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x014d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void s(f fVar, int i6) throws IOException {
        HashMap[] mapArr;
        short s6;
        boolean z6;
        short s7;
        HashMap[] mapArr2;
        HashSet hashSet;
        long j4;
        boolean z7;
        int i7;
        HashSet hashSet2;
        int i8;
        int i9;
        int unsignedShort;
        long j6;
        int i10 = i6;
        Integer numValueOf = Integer.valueOf(fVar.f7193b);
        HashSet hashSet3 = this.f7241e;
        hashSet3.add(numValueOf);
        short s8 = fVar.readShort();
        boolean z8 = l;
        if (z8) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) s8));
        }
        if (s8 <= 0) {
            return;
        }
        short s9 = 0;
        while (true) {
            mapArr = this.f7240d;
            if (s9 >= s8) {
                break;
            }
            int unsignedShort2 = fVar.readUnsignedShort();
            int unsignedShort3 = fVar.readUnsignedShort();
            int i11 = fVar.readInt();
            long j7 = ((long) fVar.f7193b) + 4;
            d dVar = (d) f7216J[i10].get(Integer.valueOf(unsignedShort2));
            if (z8) {
                s6 = s8;
                z6 = z8;
                s7 = s9;
                mapArr2 = mapArr;
                Log.d("ExifInterface", String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", Integer.valueOf(i10), Integer.valueOf(unsignedShort2), dVar != null ? dVar.f7202b : null, Integer.valueOf(unsignedShort3), Integer.valueOf(i11)));
            } else {
                s6 = s8;
                z6 = z8;
                s7 = s9;
                mapArr2 = mapArr;
            }
            if (dVar != null) {
                if (unsignedShort3 > 0) {
                    int[] iArr = f7211E;
                    if (unsignedShort3 < iArr.length) {
                        int i12 = dVar.f7203c;
                        if (i12 == 7 || unsignedShort3 == 7 || i12 == unsignedShort3 || (i7 = dVar.f7204d) == unsignedShort3 || (((i12 == 4 || i7 == 4) && unsignedShort3 == 3) || (((i12 == 9 || i7 == 9) && unsignedShort3 == 8) || ((i12 == 12 || i7 == 12) && unsignedShort3 == 11)))) {
                            if (unsignedShort3 == 7) {
                                unsignedShort3 = i12;
                            }
                            hashSet = hashSet3;
                            j4 = ((long) i11) * ((long) iArr[unsignedShort3]);
                            if (j4 < 0 || j4 > 2147483647L) {
                                if (z6) {
                                    Log.d("ExifInterface", "Skip the tag entry since the number of components is invalid: " + i11);
                                }
                                z7 = false;
                                if (z7) {
                                    fVar.b(j7);
                                } else {
                                    if (j4 > 4) {
                                        int i13 = fVar.readInt();
                                        if (z6) {
                                            hashSet2 = hashSet;
                                            Log.d("ExifInterface", "seek to data offset: " + i13);
                                        } else {
                                            hashSet2 = hashSet;
                                        }
                                        if (this.f7239c != 7) {
                                            i8 = unsignedShort2;
                                            i9 = i11;
                                            fVar.b(i13);
                                        } else {
                                            if ("MakerNote".equals(dVar.f7202b)) {
                                                this.f7245i = i13;
                                            } else {
                                                if (i10 == 6 && "ThumbnailImage".equals(dVar.f7202b)) {
                                                    this.f7246j = i13;
                                                    this.f7247k = i11;
                                                    c cVarC = c.c(6, this.f7242f);
                                                    i8 = unsignedShort2;
                                                    c cVarA = c.a(this.f7246j, this.f7242f);
                                                    i9 = i11;
                                                    c cVarA2 = c.a(this.f7247k, this.f7242f);
                                                    mapArr2[4].put("Compression", cVarC);
                                                    mapArr2[4].put("JPEGInterchangeFormat", cVarA);
                                                    mapArr2[4].put("JPEGInterchangeFormatLength", cVarA2);
                                                }
                                                fVar.b(i13);
                                            }
                                            i8 = unsignedShort2;
                                            i9 = i11;
                                            fVar.b(i13);
                                        }
                                    } else {
                                        hashSet2 = hashSet;
                                        i8 = unsignedShort2;
                                        i9 = i11;
                                    }
                                    Integer num = (Integer) f7219M.get(Integer.valueOf(i8));
                                    if (z6) {
                                        Log.d("ExifInterface", "nextIfdType: " + num + " byteCount: " + j4);
                                    }
                                    if (num != null) {
                                        if (unsignedShort3 != 3) {
                                            if (unsignedShort3 == 4) {
                                                j6 = ((long) fVar.readInt()) & 4294967295L;
                                            } else if (unsignedShort3 == 8) {
                                                unsignedShort = fVar.readShort();
                                            } else if (unsignedShort3 == 9 || unsignedShort3 == 13) {
                                                unsignedShort = fVar.readInt();
                                            } else {
                                                j6 = -1;
                                            }
                                            if (z6) {
                                                Log.d("ExifInterface", String.format("Offset: %d, tagName: %s", Long.valueOf(j6), dVar.f7202b));
                                            }
                                            int i14 = fVar.f7196e;
                                            if (j6 > 0 || (i14 != -1 && j6 >= i14)) {
                                                hashSet = hashSet2;
                                                if (z6) {
                                                    String strM = A0.a.m("Skip jump into the IFD since its offset is invalid: ", j6);
                                                    if (i14 != -1) {
                                                        strM = strM + " (total length: " + i14 + ")";
                                                    }
                                                    Log.d("ExifInterface", strM);
                                                }
                                            } else {
                                                hashSet = hashSet2;
                                                if (!hashSet.contains(Integer.valueOf((int) j6))) {
                                                    fVar.b(j6);
                                                    s(fVar, num.intValue());
                                                } else if (z6) {
                                                    Log.d("ExifInterface", "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j6 + ")");
                                                }
                                            }
                                            fVar.b(j7);
                                        } else {
                                            unsignedShort = fVar.readUnsignedShort();
                                        }
                                        j6 = unsignedShort;
                                        if (z6) {
                                        }
                                        int i142 = fVar.f7196e;
                                        if (j6 > 0) {
                                            hashSet = hashSet2;
                                            if (z6) {
                                            }
                                            fVar.b(j7);
                                        }
                                    } else {
                                        hashSet = hashSet2;
                                        int i15 = fVar.f7193b + this.f7244h;
                                        byte[] bArr = new byte[(int) j4];
                                        fVar.readFully(bArr);
                                        c cVar = new c(i15, bArr, unsignedShort3, i9);
                                        mapArr2[i6].put(dVar.f7202b, cVar);
                                        String str = dVar.f7202b;
                                        if ("DNGVersion".equals(str)) {
                                            this.f7239c = 3;
                                        }
                                        if ((("Make".equals(str) || "Model".equals(str)) && cVar.f(this.f7242f).contains("PENTAX")) || ("Compression".equals(str) && cVar.e(this.f7242f) == 65535)) {
                                            this.f7239c = 8;
                                        }
                                        if (fVar.f7193b != j7) {
                                            fVar.b(j7);
                                        }
                                    }
                                }
                                s9 = (short) (s7 + 1);
                                i10 = i6;
                                hashSet3 = hashSet;
                                s8 = s6;
                                z8 = z6;
                            } else {
                                z7 = true;
                                if (z7) {
                                }
                                s9 = (short) (s7 + 1);
                                i10 = i6;
                                hashSet3 = hashSet;
                                s8 = s6;
                                z8 = z6;
                            }
                        } else if (z6) {
                            Log.d("ExifInterface", "Skip the tag entry since data format (" + f7210D[unsignedShort3] + ") is unexpected for tag: " + dVar.f7202b);
                        }
                    }
                }
                hashSet = hashSet3;
                if (z6) {
                    Log.d("ExifInterface", "Skip the tag entry since data format is invalid: " + unsignedShort3);
                }
                j4 = 0;
                z7 = false;
                if (z7) {
                }
                s9 = (short) (s7 + 1);
                i10 = i6;
                hashSet3 = hashSet;
                s8 = s6;
                z8 = z6;
            } else if (z6) {
                Log.d("ExifInterface", "Skip the tag entry since tag number is not defined: " + unsignedShort2);
            }
            hashSet = hashSet3;
            j4 = 0;
            z7 = false;
            if (z7) {
            }
            s9 = (short) (s7 + 1);
            i10 = i6;
            hashSet3 = hashSet;
            s8 = s6;
            z8 = z6;
        }
        HashSet hashSet4 = hashSet3;
        boolean z9 = z8;
        int i16 = fVar.readInt();
        if (z9) {
            Log.d("ExifInterface", String.format("nextIfdOffset: %d", Integer.valueOf(i16)));
        }
        long j8 = i16;
        if (j8 <= 0) {
            if (z9) {
                Log.d("ExifInterface", "Stop reading file since a wrong offset may cause an infinite loop: " + i16);
                return;
            }
            return;
        }
        if (hashSet4.contains(Integer.valueOf(i16))) {
            if (z9) {
                Log.d("ExifInterface", "Stop reading file since re-reading an IFD may cause an infinite loop: " + i16);
                return;
            }
            return;
        }
        fVar.b(j8);
        if (mapArr[4].isEmpty()) {
            s(fVar, 4);
        } else if (mapArr[5].isEmpty()) {
            s(fVar, 5);
        }
    }

    public final void t(int i6, String str, String str2) {
        HashMap[] mapArr = this.f7240d;
        if (mapArr[i6].isEmpty() || mapArr[i6].get(str) == null) {
            return;
        }
        HashMap map = mapArr[i6];
        map.put(str2, map.get(str));
        mapArr[i6].remove(str);
    }

    public final void u(b bVar) throws IOException {
        c cVar;
        int iE;
        HashMap map = this.f7240d[4];
        c cVar2 = (c) map.get("Compression");
        if (cVar2 == null) {
            m(bVar, map);
            return;
        }
        int iE2 = cVar2.e(this.f7242f);
        if (iE2 != 1) {
            if (iE2 == 6) {
                m(bVar, map);
                return;
            } else if (iE2 != 7) {
                return;
            }
        }
        c cVar3 = (c) map.get("BitsPerSample");
        if (cVar3 != null) {
            int[] iArr = (int[]) cVar3.g(this.f7242f);
            int[] iArr2 = f7225o;
            if (Arrays.equals(iArr2, iArr) || (this.f7239c == 3 && (cVar = (c) map.get("PhotometricInterpretation")) != null && (((iE = cVar.e(this.f7242f)) == 1 && Arrays.equals(iArr, f7226p)) || (iE == 6 && Arrays.equals(iArr, iArr2))))) {
                c cVar4 = (c) map.get("StripOffsets");
                c cVar5 = (c) map.get("StripByteCounts");
                if (cVar4 == null || cVar5 == null) {
                    return;
                }
                long[] jArrT = C.t(cVar4.g(this.f7242f));
                long[] jArrT2 = C.t(cVar5.g(this.f7242f));
                if (jArrT == null || jArrT.length == 0) {
                    Log.w("ExifInterface", "stripOffsets should not be null or have zero length.");
                    return;
                }
                if (jArrT2 == null || jArrT2.length == 0) {
                    Log.w("ExifInterface", "stripByteCounts should not be null or have zero length.");
                    return;
                }
                if (jArrT.length != jArrT2.length) {
                    Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                    return;
                }
                long j4 = 0;
                for (long j6 : jArrT2) {
                    j4 += j6;
                }
                byte[] bArr = new byte[(int) j4];
                this.f7243g = true;
                int i6 = 0;
                int i7 = 0;
                for (int i8 = 0; i8 < jArrT.length; i8++) {
                    int i9 = (int) jArrT[i8];
                    int i10 = (int) jArrT2[i8];
                    if (i8 < jArrT.length - 1 && i9 + i10 != jArrT[i8 + 1]) {
                        this.f7243g = false;
                    }
                    int i11 = i9 - i6;
                    if (i11 < 0) {
                        Log.d("ExifInterface", "Invalid strip offset value");
                        return;
                    }
                    try {
                        bVar.a(i11);
                        int i12 = i6 + i11;
                        byte[] bArr2 = new byte[i10];
                        try {
                            bVar.readFully(bArr2);
                            i6 = i12 + i10;
                            System.arraycopy(bArr2, 0, bArr, i7, i10);
                            i7 += i10;
                        } catch (EOFException unused) {
                            Log.d("ExifInterface", "Failed to read " + i10 + " bytes.");
                            return;
                        }
                    } catch (EOFException unused2) {
                        Log.d("ExifInterface", "Failed to skip " + i11 + " bytes.");
                        return;
                    }
                }
                if (this.f7243g) {
                    long j7 = jArrT[0];
                    return;
                }
                return;
            }
        }
        if (l) {
            Log.d("ExifInterface", "Unsupported data type value");
        }
    }

    public final void v(int i6, int i7) {
        HashMap[] mapArr = this.f7240d;
        boolean zIsEmpty = mapArr[i6].isEmpty();
        boolean z6 = l;
        if (zIsEmpty || mapArr[i7].isEmpty()) {
            if (z6) {
                Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
                return;
            }
            return;
        }
        c cVar = (c) mapArr[i6].get("ImageLength");
        c cVar2 = (c) mapArr[i6].get("ImageWidth");
        c cVar3 = (c) mapArr[i7].get("ImageLength");
        c cVar4 = (c) mapArr[i7].get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            if (z6) {
                Log.d("ExifInterface", "First image does not contain valid size information");
                return;
            }
            return;
        }
        if (cVar3 == null || cVar4 == null) {
            if (z6) {
                Log.d("ExifInterface", "Second image does not contain valid size information");
                return;
            }
            return;
        }
        int iE = cVar.e(this.f7242f);
        int iE2 = cVar2.e(this.f7242f);
        int iE3 = cVar3.e(this.f7242f);
        int iE4 = cVar4.e(this.f7242f);
        if (iE >= iE3 || iE2 >= iE4) {
            return;
        }
        HashMap map = mapArr[i6];
        mapArr[i6] = mapArr[i7];
        mapArr[i7] = map;
    }

    public final void w(f fVar, int i6) throws IOException {
        c cVarC;
        c cVarC2;
        HashMap[] mapArr = this.f7240d;
        c cVar = (c) mapArr[i6].get("DefaultCropSize");
        c cVar2 = (c) mapArr[i6].get("SensorTopBorder");
        c cVar3 = (c) mapArr[i6].get("SensorLeftBorder");
        c cVar4 = (c) mapArr[i6].get("SensorBottomBorder");
        c cVar5 = (c) mapArr[i6].get("SensorRightBorder");
        if (cVar != null) {
            if (cVar.f7197a == 5) {
                e[] eVarArr = (e[]) cVar.g(this.f7242f);
                if (eVarArr == null || eVarArr.length != 2) {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(eVarArr));
                    return;
                }
                cVarC = c.b(eVarArr[0], this.f7242f);
                cVarC2 = c.b(eVarArr[1], this.f7242f);
            } else {
                int[] iArr = (int[]) cVar.g(this.f7242f);
                if (iArr == null || iArr.length != 2) {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(iArr));
                    return;
                }
                cVarC = c.c(iArr[0], this.f7242f);
                cVarC2 = c.c(iArr[1], this.f7242f);
            }
            mapArr[i6].put("ImageWidth", cVarC);
            mapArr[i6].put("ImageLength", cVarC2);
            return;
        }
        if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) {
            int iE = cVar2.e(this.f7242f);
            int iE2 = cVar4.e(this.f7242f);
            int iE3 = cVar5.e(this.f7242f);
            int iE4 = cVar3.e(this.f7242f);
            if (iE2 <= iE || iE3 <= iE4) {
                return;
            }
            c cVarC3 = c.c(iE2 - iE, this.f7242f);
            c cVarC4 = c.c(iE3 - iE4, this.f7242f);
            mapArr[i6].put("ImageLength", cVarC3);
            mapArr[i6].put("ImageWidth", cVarC4);
            return;
        }
        c cVar6 = (c) mapArr[i6].get("ImageLength");
        c cVar7 = (c) mapArr[i6].get("ImageWidth");
        if (cVar6 == null || cVar7 == null) {
            c cVar8 = (c) mapArr[i6].get("JPEGInterchangeFormat");
            c cVar9 = (c) mapArr[i6].get("JPEGInterchangeFormatLength");
            if (cVar8 == null || cVar9 == null) {
                return;
            }
            int iE5 = cVar8.e(this.f7242f);
            int iE6 = cVar8.e(this.f7242f);
            fVar.b(iE5);
            byte[] bArr = new byte[iE6];
            fVar.readFully(bArr);
            e(new b(bArr), iE5, i6);
        }
    }

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