package ῲ.䁗.K;

import android.content.res.AssetManager;
import android.util.Log;
import com.appsflyer.share.Constants;
import com.facebook.share.internal.VideoUploader;
import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment;
import com.google.android.material.progressindicator.BaseProgressIndicator;
import com.google.zxing.datamatrix.encoder.ErrorCorrection;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
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.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
import ඓ.K.K.K.C1293;

/* renamed from: ῲ.䁗.K.K  reason: contains not printable characters */
/* compiled from: ExifInterface */
public class C2346 {

    /* renamed from: В  reason: contains not printable characters */
    public static final HashMap<String, C2347>[] f8110;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public static final int[] f8111 = {8};

    /* renamed from: Ԛ  reason: contains not printable characters */
    public static final byte[] f8112 = {65, 83, 67, 73, 73, 0, 0, 0};

    /* renamed from: ؿ  reason: contains not printable characters */
    public static final byte[] f8113 = {79, 76, 89, 77, 80, 0};

    /* renamed from: ݜ  reason: contains not printable characters */
    public static final String[] f8114 = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE"};

    /* renamed from: ಯ  reason: contains not printable characters */
    public static final HashMap<Integer, Integer> f8115 = new HashMap<>();

    /* renamed from: ᆯ  reason: contains not printable characters */
    public static final C2347[] f8116 = {new C2347("ColorSpace", 55, 3)};

    /* renamed from: ሽ  reason: contains not printable characters */
    public static final C2347[] f8117 = {new C2347("SubIFDPointer", 330, 4), new C2347("ExifIFDPointer", 34665, 4), new C2347("GPSInfoIFDPointer", 34853, 4), new C2347("InteroperabilityIFDPointer", 40965, 4), new C2347("CameraSettingsIFDPointer", 8224, 1), new C2347("ImageProcessingIFDPointer", 8256, 1)};

    /* renamed from: ጒ  reason: contains not printable characters */
    public static final Charset f8118 = Charset.forName("US-ASCII");

    /* renamed from: ᑓ  reason: contains not printable characters */
    public static final C2347[] f8119 = {new C2347("InteroperabilityIndex", 1, 2)};

    /* renamed from: ᑾ  reason: contains not printable characters */
    public static final HashMap<Integer, C2347>[] f8120;

    /* renamed from: ᓆ  reason: contains not printable characters */
    public static final C2347[] f8121 = {new C2347("ExposureTime", 33434, 5), new C2347("FNumber", 33437, 5), new C2347("ExposureProgram", 34850, 3), new C2347("SpectralSensitivity", 34852, 2), new C2347("PhotographicSensitivity", 34855, 3), new C2347("OECF", 34856, 7), new C2347("ExifVersion", 36864, 2), new C2347("DateTimeOriginal", 36867, 2), new C2347("DateTimeDigitized", 36868, 2), new C2347("ComponentsConfiguration", 37121, 7), new C2347("CompressedBitsPerPixel", 37122, 5), new C2347("ShutterSpeedValue", 37377, 10), new C2347("ApertureValue", 37378, 5), new C2347("BrightnessValue", 37379, 10), new C2347("ExposureBiasValue", 37380, 10), new C2347("MaxApertureValue", 37381, 5), new C2347("SubjectDistance", 37382, 5), new C2347("MeteringMode", 37383, 3), new C2347("LightSource", 37384, 3), new C2347("Flash", 37385, 3), new C2347("FocalLength", 37386, 5), new C2347("SubjectArea", 37396, 3), new C2347("MakerNote", 37500, 7), new C2347("UserComment", 37510, 7), new C2347("SubSecTime", 37520, 2), new C2347("SubSecTimeOriginal", 37521, 2), new C2347("SubSecTimeDigitized", 37522, 2), new C2347("FlashpixVersion", 40960, 7), new C2347("ColorSpace", 40961, 3), new C2347("PixelXDimension", 40962, 3, 4), new C2347("PixelYDimension", 40963, 3, 4), new C2347("RelatedSoundFile", 40964, 2), new C2347("InteroperabilityIFDPointer", 40965, 4), new C2347("FlashEnergy", 41483, 5), new C2347("SpatialFrequencyResponse", 41484, 7), new C2347("FocalPlaneXResolution", 41486, 5), new C2347("FocalPlaneYResolution", 41487, 5), new C2347("FocalPlaneResolutionUnit", 41488, 3), new C2347("SubjectLocation", 41492, 3), new C2347("ExposureIndex", 41493, 5), new C2347("SensingMethod", 41495, 3), new C2347("FileSource", 41728, 7), new C2347("SceneType", 41729, 7), new C2347("CFAPattern", 41730, 7), new C2347("CustomRendered", 41985, 3), new C2347("ExposureMode", 41986, 3), new C2347("WhiteBalance", 41987, 3), new C2347("DigitalZoomRatio", 41988, 5), new C2347("FocalLengthIn35mmFilm", 41989, 3), new C2347("SceneCaptureType", 41990, 3), new C2347("GainControl", 41991, 3), new C2347("Contrast", 41992, 3), new C2347("Saturation", 41993, 3), new C2347("Sharpness", 41994, 3), new C2347("DeviceSettingDescription", 41995, 7), new C2347("SubjectDistanceRange", 41996, 3), new C2347("ImageUniqueID", 42016, 2), new C2347("DNGVersion", 50706, 1), new C2347("DefaultCropSize", 50720, 3, 4)};

    /* renamed from: ᓣ  reason: contains not printable characters */
    public static final byte[] f8122 = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};

    /* renamed from: ᝁ  reason: contains not printable characters */
    public static final C2347[] f8123 = {new C2347("AspectFrame", 4371, 3)};

    /* renamed from: ⶍ  reason: contains not printable characters */
    public static final C2347[][] f8124;

    /* renamed from: ゎ  reason: contains not printable characters */
    public static final C2347[] f8125 = {new C2347("NewSubfileType", 254, 4), new C2347("SubfileType", BaseProgressIndicator.MAX_ALPHA, 4), new C2347("ThumbnailImageWidth", 256, 3, 4), new C2347("ThumbnailImageLength", 257, 3, 4), new C2347("BitsPerSample", 258, 3), new C2347("Compression", 259, 3), new C2347("PhotometricInterpretation", 262, 3), new C2347("ImageDescription", BottomAppBarTopEdgeTreatment.ANGLE_UP, 2), new C2347("Make", 271, 2), new C2347("Model", 272, 2), new C2347("StripOffsets", 273, 3, 4), new C2347("Orientation", 274, 3), new C2347("SamplesPerPixel", 277, 3), new C2347("RowsPerStrip", 278, 3, 4), new C2347("StripByteCounts", 279, 3, 4), new C2347("XResolution", 282, 5), new C2347("YResolution", 283, 5), new C2347("PlanarConfiguration", 284, 3), new C2347("ResolutionUnit", 296, 3), new C2347("TransferFunction", ErrorCorrection.MODULO_VALUE, 3), new C2347("Software", 305, 2), new C2347("DateTime", 306, 2), new C2347("Artist", 315, 2), new C2347("WhitePoint", 318, 5), new C2347("PrimaryChromaticities", 319, 5), new C2347("SubIFDPointer", 330, 4), new C2347("JPEGInterchangeFormat", 513, 4), new C2347("JPEGInterchangeFormatLength", 514, 4), new C2347("YCbCrCoefficients", 529, 5), new C2347("YCbCrSubSampling", 530, 3), new C2347("YCbCrPositioning", 531, 3), new C2347("ReferenceBlackWhite", 532, 5), new C2347("Copyright", 33432, 2), new C2347("ExifIFDPointer", 34665, 4), new C2347("GPSInfoIFDPointer", 34853, 4), new C2347("DNGVersion", 50706, 1), new C2347("DefaultCropSize", 50720, 3, 4)};

    /* renamed from: ト  reason: contains not printable characters */
    public static final C2347 f8126 = new C2347("StripOffsets", 273, 3);

    /* renamed from: 㗗  reason: contains not printable characters */
    public static final byte[] f8127 = {-1, -40, -1};

    /* renamed from: 㗽  reason: contains not printable characters */
    public static SimpleDateFormat f8128 = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");

    /* renamed from: 㮔  reason: contains not printable characters */
    public static final C2347[] f8129 = {new C2347("ThumbnailImage", 256, 7), new C2347("CameraSettingsIFDPointer", 8224, 4), new C2347("ImageProcessingIFDPointer", 8256, 4)};

    /* renamed from: 㮝  reason: contains not printable characters */
    public static final HashSet<String> f8130 = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));

    /* renamed from: 㴪  reason: contains not printable characters */
    public static final C2347[] f8131 = {new C2347("GPSVersionID", 0, 1), new C2347("GPSLatitudeRef", 1, 2), new C2347("GPSLatitude", 2, 5), new C2347("GPSLongitudeRef", 3, 2), new C2347("GPSLongitude", 4, 5), new C2347("GPSAltitudeRef", 5, 1), new C2347("GPSAltitude", 6, 5), new C2347("GPSTimeStamp", 7, 5), new C2347("GPSSatellites", 8, 2), new C2347("GPSStatus", 9, 2), new C2347("GPSMeasureMode", 10, 2), new C2347("GPSDOP", 11, 5), new C2347("GPSSpeedRef", 12, 2), new C2347("GPSSpeed", 13, 5), new C2347("GPSTrackRef", 14, 2), new C2347("GPSTrack", 15, 5), new C2347("GPSImgDirectionRef", 16, 2), new C2347("GPSImgDirection", 17, 5), new C2347("GPSMapDatum", 18, 2), new C2347("GPSDestLatitudeRef", 19, 2), new C2347("GPSDestLatitude", 20, 5), new C2347("GPSDestLongitudeRef", 21, 2), new C2347("GPSDestLongitude", 22, 5), new C2347("GPSDestBearingRef", 23, 2), new C2347("GPSDestBearing", 24, 5), new C2347("GPSDestDistanceRef", 25, 2), new C2347("GPSDestDistance", 26, 5), new C2347("GPSProcessingMethod", 27, 7), new C2347("GPSAreaInformation", 28, 7), new C2347("GPSDateStamp", 29, 2), new C2347("GPSDifferential", 30, 3)};

    /* renamed from: 㶋  reason: contains not printable characters */
    public static final C2347[] f8132 = {new C2347("NewSubfileType", 254, 4), new C2347("SubfileType", BaseProgressIndicator.MAX_ALPHA, 4), new C2347("ImageWidth", 256, 3, 4), new C2347("ImageLength", 257, 3, 4), new C2347("BitsPerSample", 258, 3), new C2347("Compression", 259, 3), new C2347("PhotometricInterpretation", 262, 3), new C2347("ImageDescription", BottomAppBarTopEdgeTreatment.ANGLE_UP, 2), new C2347("Make", 271, 2), new C2347("Model", 272, 2), new C2347("StripOffsets", 273, 3, 4), new C2347("Orientation", 274, 3), new C2347("SamplesPerPixel", 277, 3), new C2347("RowsPerStrip", 278, 3, 4), new C2347("StripByteCounts", 279, 3, 4), new C2347("XResolution", 282, 5), new C2347("YResolution", 283, 5), new C2347("PlanarConfiguration", 284, 3), new C2347("ResolutionUnit", 296, 3), new C2347("TransferFunction", ErrorCorrection.MODULO_VALUE, 3), new C2347("Software", 305, 2), new C2347("DateTime", 306, 2), new C2347("Artist", 315, 2), new C2347("WhitePoint", 318, 5), new C2347("PrimaryChromaticities", 319, 5), new C2347("SubIFDPointer", 330, 4), new C2347("JPEGInterchangeFormat", 513, 4), new C2347("JPEGInterchangeFormatLength", 514, 4), new C2347("YCbCrCoefficients", 529, 5), new C2347("YCbCrSubSampling", 530, 3), new C2347("YCbCrPositioning", 531, 3), new C2347("ReferenceBlackWhite", 532, 5), new C2347("Copyright", 33432, 2), new C2347("ExifIFDPointer", 34665, 4), new C2347("GPSInfoIFDPointer", 34853, 4), new C2347("SensorTopBorder", 4, 4), new C2347("SensorLeftBorder", 5, 4), new C2347("SensorBottomBorder", 6, 4), new C2347("SensorRightBorder", 7, 4), new C2347("ISO", 23, 3), new C2347("JpgFromRaw", 46, 7)};

    /* renamed from: 㹎  reason: contains not printable characters */
    public static final byte[] f8133 = "Exif\u0000\u0000".getBytes(f8118);

    /* renamed from: 䀟  reason: contains not printable characters */
    public static final int[] f8134 = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};

    /* renamed from: 䁗  reason: contains not printable characters */
    public static final int[] f8135 = {8, 8, 8};

    /* renamed from: 䃖  reason: contains not printable characters */
    public static final C2347[] f8136 = {new C2347("PreviewImageStart", 257, 4), new C2347("PreviewImageLength", 258, 4)};

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f8137;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Set<Integer> f8138;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public int f8139;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public int f8140;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AssetManager.AssetInputStream f8141;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int f8142;

    /* renamed from: K  reason: contains not printable characters */
    public final String f8143;

    /* renamed from: 㑃  reason: contains not printable characters */
    public int f8144;

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f8145;

    /* renamed from: 㴹  reason: contains not printable characters */
    public ByteOrder f8146 = ByteOrder.BIG_ENDIAN;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final HashMap<String, C2348>[] f8147;

    /* renamed from: 㿎  reason: contains not printable characters */
    public int f8148;

    /* renamed from: ῲ.䁗.K.K$㸾  reason: contains not printable characters */
    /* compiled from: ExifInterface */
    public static class C2350 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final long f8162;

        /* renamed from: K  reason: contains not printable characters */
        public final long f8163;

        public C2350(long j, long j2) {
            if (j2 == 0) {
                this.f8163 = 0;
                this.f8162 = 1;
                return;
            }
            this.f8163 = j;
            this.f8162 = j2;
        }

        public String toString() {
            return this.f8163 + Constants.URL_PATH_DELIMITER + this.f8162;
        }
    }

    static {
        Arrays.asList(1, 6, 3, 8);
        Arrays.asList(2, 7, 4, 5);
        new int[1][0] = 4;
        C2347[] r2 = f8132;
        f8124 = new C2347[][]{r2, f8121, f8131, f8119, f8125, r2, f8129, f8136, f8123, f8116};
        C2347[][] r1 = f8124;
        f8120 = new HashMap[r1.length];
        f8110 = new HashMap[r1.length];
        f8128.setTimeZone(TimeZone.getTimeZone("UTC"));
        for (int i = 0; i < f8124.length; i++) {
            f8120[i] = new HashMap<>();
            f8110[i] = new HashMap<>();
            C2347[] r22 = f8124[i];
            for (C2347 r12 : r22) {
                f8120[i].put(Integer.valueOf(r12.f8151), r12);
                f8110[i].put(r12.f8150, r12);
            }
        }
        f8115.put(Integer.valueOf(f8117[0].f8151), 5);
        f8115.put(Integer.valueOf(f8117[1].f8151), 1);
        f8115.put(Integer.valueOf(f8117[2].f8151), 2);
        f8115.put(Integer.valueOf(f8117[3].f8151), 3);
        f8115.put(Integer.valueOf(f8117[4].f8151), 7);
        f8115.put(Integer.valueOf(f8117[5].f8151), 8);
        Pattern.compile(".*[1-9].*");
        Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
    }

    public C2346(InputStream inputStream) throws IOException {
        C2347[][] r0 = f8124;
        this.f8147 = new HashMap[r0.length];
        this.f8138 = new HashSet(r0.length);
        if (inputStream != null) {
            this.f8143 = null;
            if (inputStream instanceof AssetManager.AssetInputStream) {
                this.f8141 = (AssetManager.AssetInputStream) inputStream;
            } else {
                this.f8141 = null;
            }
            for (int i = 0; i < f8124.length; i++) {
                try {
                    this.f8147[i] = new HashMap<>();
                } catch (IOException unused) {
                } catch (Throwable th) {
                    m6153();
                    throw th;
                }
            }
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, VideoUploader.RETRY_DELAY_UNIT_MS);
            this.f8137 = m6151(bufferedInputStream);
            C2349 k = new C2349(bufferedInputStream);
            switch (this.f8137) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    m6145(k);
                    break;
                case 4:
                    m6157(k, 0, 0);
                    break;
                case 7:
                    m6155(k);
                    break;
                case 9:
                    m6149(k);
                    break;
                case 10:
                    m6161(k);
                    break;
            }
            m6160(k);
            m6153();
            return;
        }
        throw new IllegalArgumentException("inputStream cannot be null");
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public final void m6145(C2349 k) throws IOException {
        C2348 r8;
        m6156(k, k.available());
        m6150(k, 0);
        m6146(k, 0);
        m6146(k, 5);
        m6146(k, 4);
        m6154(0, 5);
        m6154(0, 4);
        m6154(5, 4);
        C2348 r82 = this.f8147[1].get("PixelXDimension");
        C2348 r4 = this.f8147[1].get("PixelYDimension");
        if (!(r82 == null || r4 == null)) {
            this.f8147[0].put("ImageWidth", r82);
            this.f8147[0].put("ImageLength", r4);
        }
        if (this.f8147[4].isEmpty() && m6159((HashMap) this.f8147[5])) {
            HashMap<String, C2348>[] hashMapArr = this.f8147;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (!m6159((HashMap) this.f8147[4])) {
            Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
        }
        if (this.f8137 == 8 && (r8 = this.f8147[1].get("MakerNote")) != null) {
            C2349 k2 = new C2349(r8.f8153);
            k2.f8158 = this.f8146;
            k2.m6171(6);
            m6150(k2, 9);
            C2348 r83 = this.f8147[9].get("ColorSpace");
            if (r83 != null) {
                this.f8147[1].put("ColorSpace", r83);
            }
        }
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public final ByteOrder m6147(C2349 k) throws IOException {
        short readShort = k.readShort();
        if (readShort == 18761) {
            return ByteOrder.LITTLE_ENDIAN;
        }
        if (readShort == 19789) {
            return ByteOrder.BIG_ENDIAN;
        }
        StringBuilder r1 = C1293.m3416("Invalid byte order: ");
        r1.append(Integer.toHexString(readShort));
        throw new IOException(r1.toString());
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C2348 m6148(String str) {
        if ("ISOSpeedRatings".equals(str)) {
            str = "PhotographicSensitivity";
        }
        for (int i = 0; i < f8124.length; i++) {
            C2348 r1 = this.f8147[i].get(str);
            if (r1 != null) {
                return r1;
            }
        }
        return null;
    }

    /* renamed from: K  reason: contains not printable characters */
    public String m6152(String str) {
        C2348 r0 = m6148(str);
        if (r0 != null) {
            if (!f8130.contains(str)) {
                return r0.m6166(this.f8146);
            }
            if (str.equals("GPSTimeStamp")) {
                int i = r0.f8155;
                if (i == 5 || i == 10) {
                    C2350[] r6 = (C2350[]) r0.m6169(this.f8146);
                    if (r6 == null || r6.length != 3) {
                        StringBuilder r02 = C1293.m3416("Invalid GPS Timestamp array. array=");
                        r02.append(Arrays.toString(r6));
                        Log.w("ExifInterface", r02.toString());
                        return null;
                    }
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) r6[0].f8163) / ((float) r6[0].f8162))), Integer.valueOf((int) (((float) r6[1].f8163) / ((float) r6[1].f8162))), Integer.valueOf((int) (((float) r6[2].f8163) / ((float) r6[2].f8162))));
                }
                StringBuilder r62 = C1293.m3416("GPS Timestamp format is not rational. format=");
                r62.append(r0.f8155);
                Log.w("ExifInterface", r62.toString());
                return null;
            }
            try {
                return Double.toString(r0.m6168(this.f8146));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0062, code lost:
        if (java.util.Arrays.equals(r1, ῲ.䁗.K.C2346.f8111) != false) goto L_0x0070;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x006c, code lost:
        if (java.util.Arrays.equals(r1, ῲ.䁗.K.C2346.f8135) != false) goto L_0x0070;
     */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0072  */
    /* JADX WARNING: Removed duplicated region for block: B:50:? A[RETURN, SYNTHETIC] */
    /* renamed from: 㴹  reason: contains not printable characters */
    public final void m6160(C2349 k) throws IOException {
        HashMap<String, C2348> hashMap = this.f8147[4];
        C2348 r1 = hashMap.get("Compression");
        if (r1 != null) {
            this.f8142 = r1.m6167(this.f8146);
            int i = this.f8142;
            boolean z = true;
            if (i != 1) {
                if (i == 6) {
                    m6158(k, hashMap);
                    return;
                } else if (i != 7) {
                    return;
                }
            }
            C2348 r12 = hashMap.get("BitsPerSample");
            if (r12 != null) {
                int[] iArr = (int[]) r12.m6169(this.f8146);
                if (!Arrays.equals(f8135, iArr)) {
                    if (this.f8137 == 3) {
                        C2348 r5 = hashMap.get("PhotometricInterpretation");
                        if (r5 != null) {
                            int r52 = r5.m6167(this.f8146);
                            if (r52 == 1) {
                            }
                            if (r52 == 6) {
                            }
                        }
                    }
                }
                if (!z) {
                    C2348 r13 = hashMap.get("StripOffsets");
                    C2348 r0 = hashMap.get("StripByteCounts");
                    if (r13 != null && r0 != null) {
                        long[] r14 = m6144(r13.m6169(this.f8146));
                        long[] r02 = m6144(r0.m6169(this.f8146));
                        if (r14 == null) {
                            Log.w("ExifInterface", "stripOffsets should not be null.");
                            return;
                        } else if (r02 == null) {
                            Log.w("ExifInterface", "stripByteCounts should not be null.");
                            return;
                        } else {
                            long j = 0;
                            for (long j2 : r02) {
                                j += j2;
                            }
                            byte[] bArr = new byte[((int) j)];
                            int i2 = 0;
                            int i3 = 0;
                            for (int i4 = 0; i4 < r14.length; i4++) {
                                int i5 = (int) r14[i4];
                                int i6 = (int) r02[i4];
                                int i7 = i5 - i2;
                                if (i7 < 0) {
                                    Log.d("ExifInterface", "Invalid strip offset value");
                                }
                                k.m6171((long) i7);
                                int i8 = i2 + i7;
                                byte[] bArr2 = new byte[i6];
                                k.read(bArr2);
                                i2 = i8 + i6;
                                System.arraycopy(bArr2, 0, bArr, i3, bArr2.length);
                                i3 += bArr2.length;
                            }
                            return;
                        }
                    } else {
                        return;
                    }
                } else {
                    return;
                }
            }
            z = false;
            if (!z) {
            }
        } else {
            this.f8142 = 6;
            m6158(k, hashMap);
        }
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public final void m6161(C2349 k) throws IOException {
        m6145(k);
        if (this.f8147[0].get("JpgFromRaw") != null) {
            m6157(k, this.f8144, 5);
        }
        C2348 r4 = this.f8147[0].get("ISO");
        C2348 r0 = this.f8147[1].get("PhotographicSensitivity");
        if (r4 != null && r0 == null) {
            this.f8147[1].put("PhotographicSensitivity", r4);
        }
    }

    /* renamed from: ῲ.䁗.K.K$K  reason: contains not printable characters */
    /* compiled from: ExifInterface */
    public static class C2349 extends InputStream implements DataInput {

        /* renamed from: ⁱ  reason: contains not printable characters */
        public static final ByteOrder f8156 = ByteOrder.BIG_ENDIAN;

        /* renamed from: 㴹  reason: contains not printable characters */
        public static final ByteOrder f8157 = ByteOrder.LITTLE_ENDIAN;

        /* renamed from: ʬ  reason: contains not printable characters */
        public ByteOrder f8158;

        /* renamed from: ඓ  reason: contains not printable characters */
        public int f8159;

        /* renamed from: ῲ  reason: contains not printable characters */
        public DataInputStream f8160;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final int f8161;

        public C2349(InputStream inputStream) throws IOException {
            this.f8158 = ByteOrder.BIG_ENDIAN;
            this.f8160 = new DataInputStream(inputStream);
            this.f8161 = this.f8160.available();
            this.f8159 = 0;
            this.f8160.mark(this.f8161);
        }

        @Override // java.io.InputStream
        public int available() throws IOException {
            return this.f8160.available();
        }

        @Override // java.io.InputStream
        public int read() throws IOException {
            this.f8159++;
            return this.f8160.read();
        }

        @Override // java.io.DataInput
        public boolean readBoolean() throws IOException {
            this.f8159++;
            return this.f8160.readBoolean();
        }

        @Override // java.io.DataInput
        public byte readByte() throws IOException {
            this.f8159++;
            if (this.f8159 <= this.f8161) {
                int read = this.f8160.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public char readChar() throws IOException {
            this.f8159 += 2;
            return this.f8160.readChar();
        }

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

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

        @Override // java.io.DataInput
        public void readFully(byte[] bArr, int i, int i2) throws IOException {
            this.f8159 += i2;
            if (this.f8159 > this.f8161) {
                throw new EOFException();
            } else if (this.f8160.read(bArr, i, i2) != i2) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override // java.io.DataInput
        public int readInt() throws IOException {
            this.f8159 += 4;
            if (this.f8159 <= this.f8161) {
                int read = this.f8160.read();
                int read2 = this.f8160.read();
                int read3 = this.f8160.read();
                int read4 = this.f8160.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.f8158;
                    if (byteOrder == f8157) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f8156) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    StringBuilder r1 = C1293.m3416("Invalid byte order: ");
                    r1.append(this.f8158);
                    throw new IOException(r1.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

        @Override // java.io.DataInput
        public long readLong() throws IOException {
            this.f8159 += 8;
            if (this.f8159 <= this.f8161) {
                int read = this.f8160.read();
                int read2 = this.f8160.read();
                int read3 = this.f8160.read();
                int read4 = this.f8160.read();
                int read5 = this.f8160.read();
                int read6 = this.f8160.read();
                int read7 = this.f8160.read();
                int read8 = this.f8160.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.f8158;
                    if (byteOrder == f8157) {
                        return (((long) read8) << 56) + (((long) read7) << 48) + (((long) read6) << 40) + (((long) read5) << 32) + (((long) read4) << 24) + (((long) read3) << 16) + (((long) read2) << 8) + ((long) read);
                    }
                    if (byteOrder == f8156) {
                        return (((long) read) << 56) + (((long) read2) << 48) + (((long) read3) << 40) + (((long) read4) << 32) + (((long) read5) << 24) + (((long) read6) << 16) + (((long) read7) << 8) + ((long) read8);
                    }
                    StringBuilder r2 = C1293.m3416("Invalid byte order: ");
                    r2.append(this.f8158);
                    throw new IOException(r2.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public short readShort() throws IOException {
            this.f8159 += 2;
            if (this.f8159 <= this.f8161) {
                int read = this.f8160.read();
                int read2 = this.f8160.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f8158;
                    if (byteOrder == f8157) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == f8156) {
                        return (short) ((read << 8) + read2);
                    }
                    StringBuilder r1 = C1293.m3416("Invalid byte order: ");
                    r1.append(this.f8158);
                    throw new IOException(r1.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public String readUTF() throws IOException {
            this.f8159 += 2;
            return this.f8160.readUTF();
        }

        @Override // java.io.DataInput
        public int readUnsignedByte() throws IOException {
            this.f8159++;
            return this.f8160.readUnsignedByte();
        }

        @Override // java.io.DataInput
        public int readUnsignedShort() throws IOException {
            this.f8159 += 2;
            if (this.f8159 <= this.f8161) {
                int read = this.f8160.read();
                int read2 = this.f8160.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f8158;
                    if (byteOrder == f8157) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == f8156) {
                        return (read << 8) + read2;
                    }
                    StringBuilder r1 = C1293.m3416("Invalid byte order: ");
                    r1.append(this.f8158);
                    throw new IOException(r1.toString());
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public int skipBytes(int i) throws IOException {
            int min = Math.min(i, this.f8161 - this.f8159);
            int i2 = 0;
            while (i2 < min) {
                i2 += this.f8160.skipBytes(min - i2);
            }
            this.f8159 += i2;
            return i2;
        }

        /* renamed from: ᨨ  reason: contains not printable characters */
        public long m6170() throws IOException {
            return ((long) readInt()) & 4294967295L;
        }

        /* renamed from: ⁱ  reason: contains not printable characters */
        public void m6171(long j) throws IOException {
            int i = this.f8159;
            if (((long) i) > j) {
                this.f8159 = 0;
                this.f8160.reset();
                this.f8160.mark(this.f8161);
            } else {
                j -= (long) i;
            }
            int i2 = (int) j;
            if (skipBytes(i2) != i2) {
                throw new IOException("Couldn't seek up to the byteCount");
            }
        }

        @Override // java.io.InputStream
        public int read(byte[] bArr, int i, int i2) throws IOException {
            int read = this.f8160.read(bArr, i, i2);
            this.f8159 += read;
            return read;
        }

        @Override // java.io.DataInput
        public void readFully(byte[] bArr) throws IOException {
            this.f8159 += bArr.length;
            if (this.f8159 > this.f8161) {
                throw new EOFException();
            } else if (this.f8160.read(bArr, 0, bArr.length) != bArr.length) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        public C2349(byte[] bArr) throws IOException {
            this(new ByteArrayInputStream(bArr));
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m6149(C2349 k) throws IOException {
        k.skipBytes(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        k.read(bArr);
        k.skipBytes(4);
        k.read(bArr2);
        int i = ByteBuffer.wrap(bArr).getInt();
        int i2 = ByteBuffer.wrap(bArr2).getInt();
        m6157(k, i, 5);
        k.m6171((long) i2);
        k.f8158 = ByteOrder.BIG_ENDIAN;
        int readInt = k.readInt();
        for (int i3 = 0; i3 < readInt; i3++) {
            int readUnsignedShort = k.readUnsignedShort();
            int readUnsignedShort2 = k.readUnsignedShort();
            if (readUnsignedShort == f8126.f8151) {
                short readShort = k.readShort();
                short readShort2 = k.readShort();
                C2348 r0 = C2348.m6162((int) readShort, this.f8146);
                C2348 r7 = C2348.m6162((int) readShort2, this.f8146);
                this.f8147[0].put("ImageLength", r0);
                this.f8147[0].put("ImageWidth", r7);
                return;
            }
            k.skipBytes(readUnsignedShort2);
        }
    }

    /* renamed from: ῲ.䁗.K.K$ʬ  reason: contains not printable characters */
    /* compiled from: ExifInterface */
    public static class C2347 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final int f8149;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final String f8150;

        /* renamed from: K  reason: contains not printable characters */
        public final int f8151;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final int f8152;

        public C2347(String str, int i, int i2) {
            this.f8150 = str;
            this.f8151 = i;
            this.f8149 = i2;
            this.f8152 = -1;
        }

        public C2347(String str, int i, int i2, int i3) {
            this.f8150 = str;
            this.f8151 = i;
            this.f8149 = i2;
            this.f8152 = i3;
        }
    }

    /* renamed from: ῲ.䁗.K.K$ῲ  reason: contains not printable characters */
    /* compiled from: ExifInterface */
    public static class C2348 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final byte[] f8153;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final int f8154;

        /* renamed from: K  reason: contains not printable characters */
        public final int f8155;

        public C2348(int i, int i2, byte[] bArr) {
            this.f8155 = i;
            this.f8154 = i2;
            this.f8153 = bArr;
        }

        /* renamed from: K  reason: contains not printable characters */
        public static C2348 m6162(int i, ByteOrder byteOrder) {
            int[] iArr = {i};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(C2346.f8134[3] * iArr.length)]);
            wrap.order(byteOrder);
            for (int i2 : iArr) {
                wrap.putShort((short) i2);
            }
            return new C2348(3, iArr.length, wrap.array());
        }

        public String toString() {
            StringBuilder r0 = C1293.m3416("(");
            r0.append(C2346.f8114[this.f8155]);
            r0.append(", data length:");
            r0.append(this.f8153.length);
            r0.append(")");
            return r0.toString();
        }

        /* renamed from: ʬ  reason: contains not printable characters */
        public String m6166(ByteOrder byteOrder) {
            Object r8 = m6169(byteOrder);
            if (r8 == null) {
                return null;
            }
            if (r8 instanceof String) {
                return (String) r8;
            }
            StringBuilder sb = new StringBuilder();
            int i = 0;
            if (r8 instanceof long[]) {
                long[] jArr = (long[]) r8;
                while (i < jArr.length) {
                    sb.append(jArr[i]);
                    i++;
                    if (i != jArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (r8 instanceof int[]) {
                int[] iArr = (int[]) r8;
                while (i < iArr.length) {
                    sb.append(iArr[i]);
                    i++;
                    if (i != iArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (r8 instanceof double[]) {
                double[] dArr = (double[]) r8;
                while (i < dArr.length) {
                    sb.append(dArr[i]);
                    i++;
                    if (i != dArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (!(r8 instanceof C2350[])) {
                return null;
            } else {
                C2350[] r82 = (C2350[]) r8;
                while (i < r82.length) {
                    sb.append(r82[i].f8163);
                    sb.append('/');
                    sb.append(r82[i].f8162);
                    i++;
                    if (i != r82.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            }
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public int m6167(ByteOrder byteOrder) {
            Object r5 = m6169(byteOrder);
            if (r5 == null) {
                throw new NumberFormatException("NULL can't be converted to a integer value");
            } else if (r5 instanceof String) {
                return Integer.parseInt((String) r5);
            } else {
                if (r5 instanceof long[]) {
                    long[] jArr = (long[]) r5;
                    if (jArr.length == 1) {
                        return (int) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r5 instanceof int[]) {
                    int[] iArr = (int[]) r5;
                    if (iArr.length == 1) {
                        return iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else {
                    throw new NumberFormatException("Couldn't find a integer value");
                }
            }
        }

        /* JADX WARNING: Removed duplicated region for block: B:139:0x019e A[SYNTHETIC, Splitter:B:139:0x019e] */
        /* JADX WARNING: Removed duplicated region for block: B:146:0x01aa A[SYNTHETIC, Splitter:B:146:0x01aa] */
        /* renamed from: 㸾  reason: contains not printable characters */
        public Object m6169(ByteOrder byteOrder) {
            Throwable th;
            C2349 k;
            IOException e;
            byte b;
            try {
                k = new C2349(this.f8153);
                try {
                    k.f8158 = byteOrder;
                    boolean z = true;
                    int i = 0;
                    switch (this.f8155) {
                        case 1:
                        case 6:
                            if (this.f8153.length != 1 || this.f8153[0] < 0 || this.f8153[0] > 1) {
                                String str = new String(this.f8153, C2346.f8118);
                                try {
                                    k.close();
                                } catch (IOException e2) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e2);
                                }
                                return str;
                            }
                            String str2 = new String(new char[]{(char) (this.f8153[0] + 48)});
                            try {
                                k.close();
                            } catch (IOException e3) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e3);
                            }
                            return str2;
                        case 2:
                        case 7:
                            if (this.f8154 >= C2346.f8112.length) {
                                int i2 = 0;
                                while (true) {
                                    if (i2 < C2346.f8112.length) {
                                        if (this.f8153[i2] != C2346.f8112[i2]) {
                                            z = false;
                                        } else {
                                            i2++;
                                        }
                                    }
                                }
                                if (z) {
                                    i = C2346.f8112.length;
                                }
                            }
                            StringBuilder sb = new StringBuilder();
                            while (i < this.f8154 && (b = this.f8153[i]) != 0) {
                                if (b >= 32) {
                                    sb.append((char) b);
                                } else {
                                    sb.append('?');
                                }
                                i++;
                            }
                            String sb2 = sb.toString();
                            try {
                                k.close();
                            } catch (IOException e4) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e4);
                            }
                            return sb2;
                        case 3:
                            int[] iArr = new int[this.f8154];
                            while (i < this.f8154) {
                                iArr[i] = k.readUnsignedShort();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e5) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e5);
                            }
                            return iArr;
                        case 4:
                            long[] jArr = new long[this.f8154];
                            while (i < this.f8154) {
                                jArr[i] = k.m6170();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e6) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e6);
                            }
                            return jArr;
                        case 5:
                            C2350[] r11 = new C2350[this.f8154];
                            while (i < this.f8154) {
                                r11[i] = new C2350(k.m6170(), k.m6170());
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e7) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e7);
                            }
                            return r11;
                        case 8:
                            int[] iArr2 = new int[this.f8154];
                            while (i < this.f8154) {
                                iArr2[i] = k.readShort();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e8) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e8);
                            }
                            return iArr2;
                        case 9:
                            int[] iArr3 = new int[this.f8154];
                            while (i < this.f8154) {
                                iArr3[i] = k.readInt();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e9) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e9);
                            }
                            return iArr3;
                        case 10:
                            C2350[] r112 = new C2350[this.f8154];
                            while (i < this.f8154) {
                                r112[i] = new C2350((long) k.readInt(), (long) k.readInt());
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e10) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                            }
                            return r112;
                        case 11:
                            double[] dArr = new double[this.f8154];
                            while (i < this.f8154) {
                                dArr[i] = (double) k.readFloat();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e11) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                            }
                            return dArr;
                        case 12:
                            double[] dArr2 = new double[this.f8154];
                            while (i < this.f8154) {
                                dArr2[i] = k.readDouble();
                                i++;
                            }
                            try {
                                k.close();
                            } catch (IOException e12) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                            }
                            return dArr2;
                        default:
                            try {
                                k.close();
                            } catch (IOException e13) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                            }
                            return null;
                    }
                } catch (IOException e14) {
                    e = e14;
                    try {
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (k != null) {
                            try {
                                k.close();
                            } catch (IOException e15) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                            }
                        }
                        return null;
                    } catch (Throwable th2) {
                        th = th2;
                        if (k != null) {
                            try {
                                k.close();
                            } catch (IOException e16) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                            }
                        }
                        throw th;
                    }
                }
            } catch (IOException e17) {
                e = e17;
                k = null;
                Log.w("ExifInterface", "IOException occurred during reading a value", e);
                if (k != null) {
                }
                return null;
            } catch (Throwable th3) {
                th = th3;
                k = null;
                if (k != null) {
                }
                throw th;
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public static C2348 m6163(long j, ByteOrder byteOrder) {
            long[] jArr = {j};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(C2346.f8134[4] * jArr.length)]);
            wrap.order(byteOrder);
            for (long j2 : jArr) {
                wrap.putInt((int) j2);
            }
            return new C2348(4, jArr.length, wrap.array());
        }

        /* renamed from: K  reason: contains not printable characters */
        public static C2348 m6164(String str) {
            byte[] bytes = (str + (char) 0).getBytes(C2346.f8118);
            return new C2348(2, bytes.length, bytes);
        }

        /* renamed from: K  reason: contains not printable characters */
        public static C2348 m6165(C2350 r6, ByteOrder byteOrder) {
            C2350[] r0 = {r6};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(C2346.f8134[5] * r0.length)]);
            wrap.order(byteOrder);
            for (C2350 r3 : r0) {
                wrap.putInt((int) r3.f8163);
                wrap.putInt((int) r3.f8162);
            }
            return new C2348(5, r0.length, wrap.array());
        }

        /* renamed from: K  reason: contains not printable characters */
        public double m6168(ByteOrder byteOrder) {
            Object r5 = m6169(byteOrder);
            if (r5 == null) {
                throw new NumberFormatException("NULL can't be converted to a double value");
            } else if (r5 instanceof String) {
                return Double.parseDouble((String) r5);
            } else {
                if (r5 instanceof long[]) {
                    long[] jArr = (long[]) r5;
                    if (jArr.length == 1) {
                        return (double) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r5 instanceof int[]) {
                    int[] iArr = (int[]) r5;
                    if (iArr.length == 1) {
                        return (double) iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r5 instanceof double[]) {
                    double[] dArr = (double[]) r5;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r5 instanceof C2350[]) {
                    C2350[] r52 = (C2350[]) r5;
                    if (r52.length == 1) {
                        C2350 r53 = r52[0];
                        return ((double) r53.f8163) / ((double) r53.f8162);
                    }
                    throw new NumberFormatException("There are more than one component");
                } else {
                    throw new NumberFormatException("Couldn't find a double value");
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final int m6151(BufferedInputStream bufferedInputStream) throws IOException {
        boolean z;
        boolean z2;
        boolean z3;
        bufferedInputStream.mark(VideoUploader.RETRY_DELAY_UNIT_MS);
        byte[] bArr = new byte[VideoUploader.RETRY_DELAY_UNIT_MS];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i = 0;
        while (true) {
            byte[] bArr2 = f8127;
            z = true;
            if (i >= bArr2.length) {
                z2 = true;
                break;
            } else if (bArr[i] != bArr2[i]) {
                z2 = false;
                break;
            } else {
                i++;
            }
        }
        if (z2) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i2 = 0;
        while (true) {
            if (i2 >= bytes.length) {
                z3 = true;
                break;
            } else if (bArr[i2] != bytes[i2]) {
                z3 = false;
                break;
            } else {
                i2++;
            }
        }
        if (z3) {
            return 9;
        }
        C2349 k = new C2349(bArr);
        this.f8146 = m6147(k);
        k.f8158 = this.f8146;
        short readShort = k.readShort();
        k.close();
        if (readShort == 20306 || readShort == 21330) {
            return 7;
        }
        C2349 k2 = new C2349(bArr);
        this.f8146 = m6147(k2);
        k2.f8158 = this.f8146;
        short readShort2 = k2.readShort();
        k2.close();
        if (readShort2 != 85) {
            z = false;
        }
        if (z) {
            return 10;
        }
        return 0;
    }

    /* JADX WARNING: Removed duplicated region for block: B:54:0x0122  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x0129  */
    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m6150(C2349 k, int i) throws IOException {
        short s;
        boolean z;
        short s2;
        long j;
        short s3;
        int i2;
        int i3;
        String str;
        int i4;
        long j2;
        int i5;
        int i6 = i;
        this.f8138.add(Integer.valueOf(k.f8159));
        if (k.f8159 + 2 <= k.f8161) {
            short readShort = k.readShort();
            if ((readShort * 12) + k.f8159 <= k.f8161 && readShort > 0) {
                short s4 = 0;
                while (s4 < readShort) {
                    int readUnsignedShort = k.readUnsignedShort();
                    int readUnsignedShort2 = k.readUnsignedShort();
                    int readInt = k.readInt();
                    long j3 = ((long) k.f8159) + 4;
                    C2347 r12 = f8120[i6].get(Integer.valueOf(readUnsignedShort));
                    if (r12 == null) {
                        Log.w("ExifInterface", "Skip the tag entry since tag number is not defined: " + readUnsignedShort);
                    } else if (readUnsignedShort2 <= 0 || readUnsignedShort2 >= f8134.length) {
                        s2 = readShort;
                        s = s4;
                        Log.w("ExifInterface", "Skip the tag entry since data format is invalid: " + readUnsignedShort2);
                        j = 0;
                        z = false;
                        if (z) {
                            k.m6171(j3);
                            s3 = s2;
                        } else {
                            if (j > 4) {
                                int readInt2 = k.readInt();
                                int i7 = this.f8137;
                                s3 = s2;
                                if (i7 == 7) {
                                    if ("MakerNote".equals(r12.f8150)) {
                                        this.f8140 = readInt2;
                                    } else if (i6 == 6 && "ThumbnailImage".equals(r12.f8150)) {
                                        this.f8145 = readInt2;
                                        this.f8139 = readInt;
                                        C2348 r5 = C2348.m6162(6, this.f8146);
                                        i2 = readUnsignedShort2;
                                        i3 = readInt;
                                        C2348 r8 = C2348.m6163((long) this.f8145, this.f8146);
                                        j2 = j3;
                                        C2348 r9 = C2348.m6163((long) this.f8139, this.f8146);
                                        this.f8147[4].put("Compression", r5);
                                        this.f8147[4].put("JPEGInterchangeFormat", r8);
                                        this.f8147[4].put("JPEGInterchangeFormatLength", r9);
                                    }
                                    i2 = readUnsignedShort2;
                                    i3 = readInt;
                                    j2 = j3;
                                } else {
                                    i2 = readUnsignedShort2;
                                    i3 = readInt;
                                    j2 = j3;
                                    if (i7 == 10 && "JpgFromRaw".equals(r12.f8150)) {
                                        this.f8144 = readInt2;
                                    }
                                }
                                long j4 = (long) readInt2;
                                str = "Compression";
                                if (j4 + j <= ((long) k.f8161)) {
                                    k.m6171(j4);
                                    j3 = j2;
                                } else {
                                    Log.w("ExifInterface", "Skip the tag entry since data offset is invalid: " + readInt2);
                                    k.m6171(j2);
                                }
                            } else {
                                i2 = readUnsignedShort2;
                                i3 = readInt;
                                s3 = s2;
                                str = "Compression";
                            }
                            Integer num = f8115.get(Integer.valueOf(readUnsignedShort));
                            if (num != null) {
                                long j5 = -1;
                                if (i2 != 3) {
                                    if (i2 == 4) {
                                        j5 = k.m6170();
                                    } else if (i2 == 8) {
                                        i4 = k.readShort();
                                    } else if (i2 == 9 || i2 == 13) {
                                        i4 = k.readInt();
                                    }
                                    if (j5 > 0 || j5 >= ((long) k.f8161)) {
                                        Log.w("ExifInterface", "Skip jump into the IFD since its offset is invalid: " + j5);
                                    } else if (!this.f8138.contains(Integer.valueOf((int) j5))) {
                                        k.m6171(j5);
                                        m6150(k, num.intValue());
                                    } else {
                                        Log.w("ExifInterface", "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j5 + ")");
                                    }
                                    k.m6171(j3);
                                } else {
                                    i4 = k.readUnsignedShort();
                                }
                                j5 = (long) i4;
                                if (j5 > 0) {
                                }
                                Log.w("ExifInterface", "Skip jump into the IFD since its offset is invalid: " + j5);
                                k.m6171(j3);
                            } else {
                                byte[] bArr = new byte[((int) j)];
                                k.readFully(bArr);
                                C2348 r3 = new C2348(i2, i3, bArr);
                                this.f8147[i].put(r12.f8150, r3);
                                if ("DNGVersion".equals(r12.f8150)) {
                                    this.f8137 = 3;
                                }
                                if ((("Make".equals(r12.f8150) || "Model".equals(r12.f8150)) && r3.m6166(this.f8146).contains("PENTAX")) || (str.equals(r12.f8150) && r3.m6167(this.f8146) == 65535)) {
                                    this.f8137 = 8;
                                }
                                if (((long) k.f8159) != j3) {
                                    k.m6171(j3);
                                }
                            }
                        }
                        s4 = (short) (s + 1);
                        i6 = i;
                        readShort = s3;
                    } else {
                        int i8 = r12.f8149;
                        if (!(i8 == 7 || readUnsignedShort2 == 7 || i8 == readUnsignedShort2 || (i5 = r12.f8152) == readUnsignedShort2 || ((i8 == 4 || i5 == 4) && readUnsignedShort2 == 3) || (((r12.f8149 == 9 || r12.f8152 == 9) && readUnsignedShort2 == 8) || ((r12.f8149 == 12 || r12.f8152 == 12) && readUnsignedShort2 == 11)))) {
                            StringBuilder r52 = C1293.m3416("Skip the tag entry since data format (");
                            r52.append(f8114[readUnsignedShort2]);
                            r52.append(") is unexpected for tag: ");
                            r52.append(r12.f8150);
                            Log.w("ExifInterface", r52.toString());
                        } else {
                            if (readUnsignedShort2 == 7) {
                                readUnsignedShort2 = r12.f8149;
                            }
                            s2 = readShort;
                            s = s4;
                            j = ((long) readInt) * ((long) f8134[readUnsignedShort2]);
                            if (j < 0 || j > 2147483647L) {
                                Log.w("ExifInterface", "Skip the tag entry since the number of components is invalid: " + readInt);
                                z = false;
                                if (z) {
                                }
                                s4 = (short) (s + 1);
                                i6 = i;
                                readShort = s3;
                            } else {
                                z = true;
                                if (z) {
                                }
                                s4 = (short) (s + 1);
                                i6 = i;
                                readShort = s3;
                            }
                        }
                    }
                    s2 = readShort;
                    s = s4;
                    j = 0;
                    z = false;
                    if (z) {
                    }
                    s4 = (short) (s + 1);
                    i6 = i;
                    readShort = s3;
                }
                if (k.f8159 + 4 <= k.f8161) {
                    int readInt3 = k.readInt();
                    long j6 = (long) readInt3;
                    if (j6 <= 0 || readInt3 >= k.f8161) {
                        Log.w("ExifInterface", "Stop reading file since a wrong offset may cause an infinite loop: " + readInt3);
                    } else if (!this.f8138.contains(Integer.valueOf(readInt3))) {
                        k.m6171(j6);
                        if (this.f8147[4].isEmpty()) {
                            m6150(k, 4);
                        } else if (this.f8147[5].isEmpty()) {
                            m6150(k, 5);
                        }
                    } else {
                        Log.w("ExifInterface", "Stop reading file since re-reading an IFD may cause an infinite loop: " + readInt3);
                    }
                }
            }
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public final void m6146(C2349 k, int i) throws IOException {
        C2348 r0;
        C2348 r10;
        C2348 r02;
        C2348 r03 = this.f8147[i].get("DefaultCropSize");
        C2348 r1 = this.f8147[i].get("SensorTopBorder");
        C2348 r2 = this.f8147[i].get("SensorLeftBorder");
        C2348 r3 = this.f8147[i].get("SensorBottomBorder");
        C2348 r4 = this.f8147[i].get("SensorRightBorder");
        if (r03 != null) {
            if (r03.f8155 == 5) {
                C2350[] r102 = (C2350[]) r03.m6169(this.f8146);
                if (r102 == null || r102.length != 2) {
                    StringBuilder r11 = C1293.m3416("Invalid crop size values. cropSize=");
                    r11.append(Arrays.toString(r102));
                    Log.w("ExifInterface", r11.toString());
                    return;
                }
                r02 = C2348.m6165(r102[0], this.f8146);
                r10 = C2348.m6165(r102[1], this.f8146);
            } else {
                int[] iArr = (int[]) r03.m6169(this.f8146);
                if (iArr == null || iArr.length != 2) {
                    StringBuilder r112 = C1293.m3416("Invalid crop size values. cropSize=");
                    r112.append(Arrays.toString(iArr));
                    Log.w("ExifInterface", r112.toString());
                    return;
                }
                r02 = C2348.m6162(iArr[0], this.f8146);
                r10 = C2348.m6162(iArr[1], this.f8146);
            }
            this.f8147[i].put("ImageWidth", r02);
            this.f8147[i].put("ImageLength", r10);
        } else if (r1 == null || r2 == null || r3 == null || r4 == null) {
            C2348 r04 = this.f8147[i].get("ImageLength");
            C2348 r12 = this.f8147[i].get("ImageWidth");
            if ((r04 == null || r12 == null) && (r0 = this.f8147[i].get("JPEGInterchangeFormat")) != null) {
                m6157(k, r0.m6167(this.f8146), i);
            }
        } else {
            int r103 = r1.m6167(this.f8146);
            int r05 = r3.m6167(this.f8146);
            int r13 = r4.m6167(this.f8146);
            int r22 = r2.m6167(this.f8146);
            if (r05 > r103 && r13 > r22) {
                C2348 r104 = C2348.m6162(r05 - r103, this.f8146);
                C2348 r06 = C2348.m6162(r13 - r22, this.f8146);
                this.f8147[i].put("ImageLength", r104);
                this.f8147[i].put("ImageWidth", r06);
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x0055 A[FALL_THROUGH] */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x00ec  */
    /* JADX WARNING: Removed duplicated region for block: B:74:0x00fd A[SYNTHETIC] */
    /* renamed from: K  reason: contains not printable characters */
    public final void m6157(C2349 k, int i, int i2) throws IOException {
        k.f8158 = ByteOrder.BIG_ENDIAN;
        k.m6171((long) i);
        byte readByte = k.readByte();
        if (readByte == -1) {
            int i3 = i + 1;
            if (k.readByte() == -40) {
                int i4 = i3 + 1;
                while (true) {
                    byte readByte2 = k.readByte();
                    if (readByte2 == -1) {
                        byte readByte3 = k.readByte();
                        int i5 = i4 + 1 + 1;
                        if (readByte3 == -39 || readByte3 == -38) {
                            k.f8158 = this.f8146;
                        } else {
                            int readUnsignedShort = k.readUnsignedShort() - 2;
                            int i6 = i5 + 2;
                            if (readUnsignedShort >= 0) {
                                if (readByte3 == -31) {
                                    if (readUnsignedShort >= 6) {
                                        byte[] bArr = new byte[6];
                                        if (k.read(bArr) == 6) {
                                            i6 += 6;
                                            readUnsignedShort -= 6;
                                            if (Arrays.equals(bArr, f8133)) {
                                                if (readUnsignedShort > 0) {
                                                    this.f8148 = i6;
                                                    byte[] bArr2 = new byte[readUnsignedShort];
                                                    if (k.read(bArr2) == readUnsignedShort) {
                                                        i6 += readUnsignedShort;
                                                        C2349 k2 = new C2349(bArr2);
                                                        m6156(k2, bArr2.length);
                                                        m6150(k2, i2);
                                                    } else {
                                                        throw new IOException("Invalid exif");
                                                    }
                                                } else {
                                                    throw new IOException("Invalid exif");
                                                }
                                            }
                                        } else {
                                            throw new IOException("Invalid exif");
                                        }
                                    }
                                    if (readUnsignedShort < 0) {
                                    }
                                } else if (readByte3 != -2) {
                                    switch (readByte3) {
                                        default:
                                            switch (readByte3) {
                                                default:
                                                    switch (readByte3) {
                                                        default:
                                                            switch (readByte3) {
                                                            }
                                                        case -55:
                                                        case -54:
                                                        case -53:
                                                            if (k.skipBytes(1) == 1) {
                                                                this.f8147[i2].put("ImageLength", C2348.m6163((long) k.readUnsignedShort(), this.f8146));
                                                                this.f8147[i2].put("ImageWidth", C2348.m6163((long) k.readUnsignedShort(), this.f8146));
                                                                readUnsignedShort -= 5;
                                                                break;
                                                            } else {
                                                                throw new IOException("Invalid SOFx");
                                                            }
                                                    }
                                                case -59:
                                                case -58:
                                                case -57:
                                                    break;
                                            }
                                        case -64:
                                        case -63:
                                        case -62:
                                        case -61:
                                            break;
                                    }
                                    if (readUnsignedShort < 0) {
                                        throw new IOException("Invalid length");
                                    } else if (k.skipBytes(readUnsignedShort) == readUnsignedShort) {
                                        i4 = i6 + readUnsignedShort;
                                    } else {
                                        throw new IOException("Invalid JPEG segment");
                                    }
                                } else {
                                    byte[] bArr3 = new byte[readUnsignedShort];
                                    if (k.read(bArr3) != readUnsignedShort) {
                                        throw new IOException("Invalid exif");
                                    } else if (m6152("UserComment") == null) {
                                        this.f8147[1].put("UserComment", C2348.m6164(new String(bArr3, f8118)));
                                    }
                                }
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 0) {
                                }
                            } else {
                                throw new IOException("Invalid length");
                            }
                        }
                    } else {
                        StringBuilder r10 = C1293.m3416("Invalid marker:");
                        r10.append(Integer.toHexString(readByte2 & 255));
                        throw new IOException(r10.toString());
                    }
                }
                k.f8158 = this.f8146;
                return;
            }
            StringBuilder r102 = C1293.m3416("Invalid marker: ");
            r102.append(Integer.toHexString(readByte & 255));
            throw new IOException(r102.toString());
        }
        StringBuilder r103 = C1293.m3416("Invalid marker: ");
        r103.append(Integer.toHexString(readByte & 255));
        throw new IOException(r103.toString());
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6155(C2349 k) throws IOException {
        m6145(k);
        C2348 r7 = this.f8147[1].get("MakerNote");
        if (r7 != null) {
            C2349 k2 = new C2349(r7.f8153);
            k2.f8158 = this.f8146;
            byte[] bArr = new byte[f8113.length];
            k2.readFully(bArr);
            k2.m6171(0);
            byte[] bArr2 = new byte[f8122.length];
            k2.readFully(bArr2);
            if (Arrays.equals(bArr, f8113)) {
                k2.m6171(8);
            } else if (Arrays.equals(bArr2, f8122)) {
                k2.m6171(12);
            }
            m6150(k2, 6);
            C2348 r72 = this.f8147[7].get("PreviewImageStart");
            C2348 r1 = this.f8147[7].get("PreviewImageLength");
            if (!(r72 == null || r1 == null)) {
                this.f8147[5].put("JPEGInterchangeFormat", r72);
                this.f8147[5].put("JPEGInterchangeFormatLength", r1);
            }
            C2348 r73 = this.f8147[8].get("AspectFrame");
            if (r73 != null) {
                int[] iArr = (int[]) r73.m6169(this.f8146);
                if (iArr == null || iArr.length != 4) {
                    StringBuilder r0 = C1293.m3416("Invalid aspect frame values. frame=");
                    r0.append(Arrays.toString(iArr));
                    Log.w("ExifInterface", r0.toString());
                } else if (iArr[2] > iArr[0] && iArr[3] > iArr[1]) {
                    int i = (iArr[2] - iArr[0]) + 1;
                    int i2 = (iArr[3] - iArr[1]) + 1;
                    if (i < i2) {
                        int i3 = i + i2;
                        i2 = i3 - i2;
                        i = i3 - i2;
                    }
                    C2348 r74 = C2348.m6162(i, this.f8146);
                    C2348 r02 = C2348.m6162(i2, this.f8146);
                    this.f8147[0].put("ImageWidth", r74);
                    this.f8147[0].put("ImageLength", r02);
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6153() {
        String r0 = m6152("DateTimeOriginal");
        if (r0 != null && m6152("DateTime") == null) {
            this.f8147[0].put("DateTime", C2348.m6164(r0));
        }
        if (m6152("ImageWidth") == null) {
            this.f8147[0].put("ImageWidth", C2348.m6163(0L, this.f8146));
        }
        if (m6152("ImageLength") == null) {
            this.f8147[0].put("ImageLength", C2348.m6163(0L, this.f8146));
        }
        if (m6152("Orientation") == null) {
            this.f8147[0].put("Orientation", C2348.m6163(0L, this.f8146));
        }
        if (m6152("LightSource") == null) {
            this.f8147[1].put("LightSource", C2348.m6163(0L, this.f8146));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6156(C2349 k, int i) throws IOException {
        this.f8146 = m6147(k);
        k.f8158 = this.f8146;
        int readUnsignedShort = k.readUnsignedShort();
        int i2 = this.f8137;
        if (i2 == 7 || i2 == 10 || readUnsignedShort == 42) {
            int readInt = k.readInt();
            if (readInt < 8 || readInt >= i) {
                throw new IOException(C1293.m3408("Invalid first Ifd offset: ", readInt));
            }
            int i3 = readInt - 8;
            if (i3 > 0 && k.skipBytes(i3) != i3) {
                throw new IOException(C1293.m3408("Couldn't jump to first Ifd: ", i3));
            }
            return;
        }
        StringBuilder r5 = C1293.m3416("Invalid start code: ");
        r5.append(Integer.toHexString(readUnsignedShort));
        throw new IOException(r5.toString());
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6158(C2349 k, HashMap hashMap) throws IOException {
        int i;
        C2348 r0 = (C2348) hashMap.get("JPEGInterchangeFormat");
        C2348 r5 = (C2348) hashMap.get("JPEGInterchangeFormatLength");
        if (r0 != null && r5 != null) {
            int r02 = r0.m6167(this.f8146);
            int min = Math.min(r5.m6167(this.f8146), k.available() - r02);
            int i2 = this.f8137;
            if (i2 == 4 || i2 == 9 || i2 == 10) {
                i = this.f8148;
            } else {
                if (i2 == 7) {
                    i = this.f8140;
                }
                if (r02 > 0 && min > 0 && this.f8143 == null && this.f8141 == null) {
                    k.m6171((long) r02);
                    k.readFully(new byte[min]);
                    return;
                }
                return;
            }
            r02 += i;
            if (r02 > 0) {
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final boolean m6159(HashMap hashMap) throws IOException {
        C2348 r0 = (C2348) hashMap.get("ImageLength");
        C2348 r3 = (C2348) hashMap.get("ImageWidth");
        if (r0 == null || r3 == null) {
            return false;
        }
        return r0.m6167(this.f8146) <= 512 && r3.m6167(this.f8146) <= 512;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6154(int i, int i2) throws IOException {
        if (!this.f8147[i].isEmpty() && !this.f8147[i2].isEmpty()) {
            C2348 r0 = this.f8147[i].get("ImageLength");
            C2348 r2 = this.f8147[i].get("ImageWidth");
            C2348 r1 = this.f8147[i2].get("ImageLength");
            C2348 r3 = this.f8147[i2].get("ImageWidth");
            if (r0 != null && r2 != null && r1 != null && r3 != null) {
                int r02 = r0.m6167(this.f8146);
                int r22 = r2.m6167(this.f8146);
                int r12 = r1.m6167(this.f8146);
                int r32 = r3.m6167(this.f8146);
                if (r02 < r12 && r22 < r32) {
                    HashMap<String, C2348>[] hashMapArr = this.f8147;
                    HashMap<String, C2348> hashMap = hashMapArr[i];
                    hashMapArr[i] = hashMapArr[i2];
                    hashMapArr[i2] = hashMap;
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static long[] m6144(Object obj) {
        if (obj instanceof int[]) {
            int[] iArr = (int[]) obj;
            long[] jArr = new long[iArr.length];
            for (int i = 0; i < iArr.length; i++) {
                jArr[i] = (long) iArr[i];
            }
            return jArr;
        } else if (obj instanceof long[]) {
            return (long[]) obj;
        } else {
            return null;
        }
    }
}
