ViMusic v0.5.4版本的 MD5 值为:e5d76df875234aa34db5af7d13eb379b

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


package m2;

import android.content.res.AssetManager;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.OsConstants;
import android.util.Log;
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.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
import o2.o;
public final class g {
    public static final byte[] A;
    public static final String[] B;
    public static final int[] C;
    public static final byte[] D;
    public static final d E;
    public static final d[][] F;
    public static final d[] G;
    public static final HashMap[] H;
    public static final HashMap[] I;
    public static final HashSet J;
    public static final HashMap K;
    public static final Charset L;
    public static final byte[] M;
    public static final byte[] N;
    public static final boolean f7288l = Log.isLoggable("ExifInterface", 3);
    public static final int[] f7289m;
    public static final int[] f7290n;
    public static final byte[] f7291o;
    public static final byte[] f7292p;
    public static final byte[] f7293q;
    public static final byte[] f7294r;
    public static final byte[] f7295s;
    public static final byte[] f7296t;
    public static final byte[] f7297u;
    public static final byte[] f7298v;
    public static final byte[] f7299w;
    public static final byte[] f7300x;
    public static final byte[] f7301y;
    public static final byte[] f7302z;
    public FileDescriptor f7303a;
    public AssetManager.AssetInputStream f7304b;
    public int f7305c;
    public final HashMap[] f7306d;
    public HashSet f7307e;
    public ByteOrder f7308f;
    public boolean f7309g;
    public int f7310h;
    public int f7311i;
    public int f7312j;
    public int f7313k;

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

    public g(i4.i iVar) {
        boolean z9;
        d[][] dVarArr = F;
        this.f7306d = new HashMap[dVarArr.length];
        this.f7307e = new HashSet(dVarArr.length);
        this.f7308f = ByteOrder.BIG_ENDIAN;
        FileDescriptor fileDescriptor = null;
        boolean z10 = true;
        if (iVar instanceof AssetManager.AssetInputStream) {
            this.f7304b = (AssetManager.AssetInputStream) iVar;
        } else {
            if (iVar instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) iVar;
                try {
                    h.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                    z9 = true;
                } catch (Exception unused) {
                    if (f7288l) {
                        Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                    }
                    z9 = false;
                }
                if (z9) {
                    this.f7304b = null;
                    fileDescriptor = fileInputStream.getFD();
                }
            }
            this.f7304b = null;
        }
        this.f7303a = fileDescriptor;
        for (int i10 = 0; i10 < F.length; i10++) {
            try {
                try {
                    this.f7306d[i10] = new HashMap();
                } finally {
                    a();
                    if (f7288l) {
                        p();
                    }
                }
            } catch (IOException | UnsupportedOperationException e10) {
                boolean z11 = f7288l;
                if (z11) {
                    Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e10);
                }
                a();
                if (!z11) {
                    return;
                }
            }
        }
        BufferedInputStream bufferedInputStream = new BufferedInputStream(iVar, 5000);
        int f10 = f(bufferedInputStream);
        this.f7305c = f10;
        if ((f10 == 4 || f10 == 9 || f10 == 13 || f10 == 14) ? false : false) {
            f fVar = new f(bufferedInputStream);
            int i11 = this.f7305c;
            if (i11 == 12) {
                d(fVar);
            } else if (i11 == 7) {
                g(fVar);
            } else if (i11 == 10) {
                k(fVar);
            } else {
                j(fVar);
            }
            fVar.b(this.f7310h);
            u(fVar);
        } else {
            b bVar = new b(bufferedInputStream);
            int i12 = this.f7305c;
            if (i12 == 4) {
                e(bVar, 0, 0);
            } else if (i12 == 13) {
                h(bVar);
            } else if (i12 == 9) {
                i(bVar);
            } else if (i12 == 14) {
                l(bVar);
            }
        }
    }

    public static ByteOrder q(b bVar) {
        short readShort = bVar.readShort();
        if (readShort != 18761) {
            if (readShort == 19789) {
                if (f7288l) {
                    Log.d("ExifInterface", "readExifSegment: Byte Align MM");
                }
                return ByteOrder.BIG_ENDIAN;
            }
            StringBuilder s9 = a.g.s("Invalid byte order: ");
            s9.append(Integer.toHexString(readShort));
            throw new IOException(s9.toString());
        }
        if (f7288l) {
            Log.d("ExifInterface", "readExifSegment: Byte Align II");
        }
        return ByteOrder.LITTLE_ENDIAN;
    }

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

    public final String b(String str) {
        String sb;
        c c10 = c(str);
        if (c10 != null) {
            if (!J.contains(str)) {
                return c10.g(this.f7308f);
            }
            if (str.equals("GPSTimeStamp")) {
                int i10 = c10.f7278a;
                if (i10 != 5 && i10 != 10) {
                    StringBuilder s9 = a.g.s("GPS Timestamp format is not rational. format=");
                    s9.append(c10.f7278a);
                    sb = s9.toString();
                } else {
                    e[] eVarArr = (e[]) c10.h(this.f7308f);
                    if (eVarArr != null && eVarArr.length == 3) {
                        e eVar = eVarArr[0];
                        e eVar2 = eVarArr[1];
                        e eVar3 = eVarArr[2];
                        return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVar.f7286a) / ((float) eVar.f7287b))), Integer.valueOf((int) (((float) eVar2.f7286a) / ((float) eVar2.f7287b))), Integer.valueOf((int) (((float) eVar3.f7286a) / ((float) eVar3.f7287b))));
                    }
                    StringBuilder s10 = a.g.s("Invalid GPS Timestamp array. array=");
                    s10.append(Arrays.toString(eVarArr));
                    sb = s10.toString();
                }
                Log.w("ExifInterface", sb);
                return null;
            }
            try {
                return Double.toString(c10.e(this.f7308f));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

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

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

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

    public final int f(BufferedInputStream bufferedInputStream) {
        boolean z9;
        boolean z10;
        b bVar;
        b bVar2;
        boolean z11;
        b bVar3;
        b bVar4;
        boolean z12;
        b bVar5;
        b bVar6;
        boolean z13;
        boolean z14;
        boolean z15;
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr2 = f7291o;
            if (i10 < bArr2.length) {
                if (bArr[i10] != bArr2[i10]) {
                    z9 = false;
                    break;
                }
                i10++;
            } else {
                z9 = true;
                break;
            }
        }
        if (z9) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i11 = 0;
        while (true) {
            if (i11 < bytes.length) {
                if (bArr[i11] != bytes[i11]) {
                    z10 = false;
                    break;
                }
                i11++;
            } else {
                z10 = true;
                break;
            }
        }
        if (z10) {
            return 9;
        }
        try {
            bVar2 = new b(bArr);
            try {
                long readInt = bVar2.readInt();
                byte[] bArr3 = new byte[4];
                bVar2.read(bArr3);
                if (Arrays.equals(bArr3, f7292p)) {
                    long j10 = 16;
                    if (readInt == 1) {
                        readInt = bVar2.readLong();
                        if (readInt < 16) {
                        }
                    } else {
                        j10 = 8;
                    }
                    long j11 = 5000;
                    if (readInt > j11) {
                        readInt = j11;
                    }
                    long j12 = readInt - j10;
                    if (j12 >= 8) {
                        byte[] bArr4 = new byte[4];
                        boolean z16 = false;
                        boolean z17 = false;
                        for (long j13 = 0; j13 < j12 / 4 && bVar2.read(bArr4) == 4; j13++) {
                            if (j13 != 1) {
                                if (Arrays.equals(bArr4, f7293q)) {
                                    z16 = true;
                                } else if (Arrays.equals(bArr4, f7294r)) {
                                    z17 = true;
                                }
                                if (z16 && z17) {
                                    bVar2.close();
                                    z11 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e10) {
                e = e10;
                try {
                    if (f7288l) {
                        Log.d("ExifInterface", "Exception parsing HEIF file type box.", e);
                    }
                } catch (Throwable th) {
                    th = th;
                    bVar = bVar2;
                    bVar2 = bVar;
                    if (bVar2 != null) {
                        bVar2.close();
                    }
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
                if (bVar2 != null) {
                }
                throw th;
            }
        } catch (Exception e11) {
            e = e11;
            bVar2 = null;
        } catch (Throwable th3) {
            th = th3;
            bVar = null;
            bVar2 = bVar;
            if (bVar2 != null) {
            }
            throw th;
        }
        bVar2.close();
        z11 = false;
        if (z11) {
            return 12;
        }
        try {
            bVar4 = new b(bArr);
            try {
                ByteOrder q9 = q(bVar4);
                this.f7308f = q9;
                bVar4.f7275r = q9;
                short readShort = bVar4.readShort();
                if (readShort != 20306 && readShort != 21330) {
                    z12 = false;
                } else {
                    z12 = true;
                }
                bVar4.close();
            } catch (Exception unused) {
                if (bVar4 != null) {
                    bVar4.close();
                }
                z12 = false;
                if (!z12) {
                }
            } catch (Throwable th4) {
                th = th4;
                bVar3 = bVar4;
                if (bVar3 != null) {
                    bVar3.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
            bVar4 = null;
        } catch (Throwable th5) {
            th = th5;
            bVar3 = null;
        }
        if (!z12) {
            return 7;
        }
        try {
            b bVar7 = new b(bArr);
            try {
                ByteOrder q10 = q(bVar7);
                this.f7308f = q10;
                bVar7.f7275r = q10;
                if (bVar7.readShort() == 85) {
                    z13 = true;
                } else {
                    z13 = false;
                }
                bVar7.close();
            } catch (Exception unused3) {
                bVar6 = bVar7;
                if (bVar6 != null) {
                    bVar6.close();
                }
                z13 = false;
                if (!z13) {
                }
            } catch (Throwable th6) {
                th = th6;
                bVar5 = bVar7;
                if (bVar5 != null) {
                    bVar5.close();
                }
                throw th;
            }
        } catch (Exception unused4) {
            bVar6 = null;
        } catch (Throwable th7) {
            th = th7;
            bVar5 = null;
        }
        if (!z13) {
            return 10;
        }
        int i12 = 0;
        while (true) {
            byte[] bArr5 = f7297u;
            if (i12 < bArr5.length) {
                if (bArr[i12] != bArr5[i12]) {
                    z14 = false;
                    break;
                }
                i12++;
            } else {
                z14 = true;
                break;
            }
        }
        if (z14) {
            return 13;
        }
        int i13 = 0;
        while (true) {
            byte[] bArr6 = f7301y;
            if (i13 < bArr6.length) {
                if (bArr[i13] != bArr6[i13]) {
                    break;
                }
                i13++;
            } else {
                int i14 = 0;
                while (true) {
                    byte[] bArr7 = f7302z;
                    if (i14 < bArr7.length) {
                        if (bArr[f7301y.length + i14 + 4] != bArr7[i14]) {
                            break;
                        }
                        i14++;
                    } else {
                        z15 = true;
                        break;
                    }
                }
            }
        }
        z15 = false;
        if (!z15) {
            return 0;
        }
        return 14;
    }

    public final void g(f fVar) {
        c cVar;
        c cVar2;
        c cVar3;
        int i10;
        int i11;
        long j10;
        j(fVar);
        c cVar4 = (c) this.f7306d[1].get("MakerNote");
        if (cVar4 != null) {
            f fVar2 = new f(cVar4.f7281d);
            fVar2.f7275r = this.f7308f;
            byte[] bArr = f7295s;
            byte[] bArr2 = new byte[bArr.length];
            fVar2.readFully(bArr2);
            fVar2.b(0L);
            byte[] bArr3 = f7296t;
            byte[] bArr4 = new byte[bArr3.length];
            fVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                j10 = 8;
            } else {
                j10 = Arrays.equals(bArr4, bArr3) ? 12L : 12L;
                s(fVar2, 6);
                cVar = (c) this.f7306d[7].get("PreviewImageStart");
                cVar2 = (c) this.f7306d[7].get("PreviewImageLength");
                if (cVar != null && cVar2 != null) {
                    this.f7306d[5].put("JPEGInterchangeFormat", cVar);
                    this.f7306d[5].put("JPEGInterchangeFormatLength", cVar2);
                }
                cVar3 = (c) this.f7306d[8].get("AspectFrame");
                if (cVar3 == null) {
                    int[] iArr = (int[]) cVar3.h(this.f7308f);
                    if (iArr != null && iArr.length == 4) {
                        int i12 = iArr[2];
                        int i13 = iArr[0];
                        if (i12 > i13 && (i10 = iArr[3]) > (i11 = iArr[1])) {
                            int i14 = (i12 - i13) + 1;
                            int i15 = (i10 - i11) + 1;
                            if (i14 < i15) {
                                int i16 = i14 + i15;
                                i15 = i16 - i15;
                                i14 = i16 - i15;
                            }
                            c d2 = c.d(i14, this.f7308f);
                            c d4 = c.d(i15, this.f7308f);
                            this.f7306d[0].put("ImageWidth", d2);
                            this.f7306d[0].put("ImageLength", d4);
                            return;
                        }
                        return;
                    }
                    StringBuilder s9 = a.g.s("Invalid aspect frame values. frame=");
                    s9.append(Arrays.toString(iArr));
                    Log.w("ExifInterface", s9.toString());
                    return;
                }
                return;
            }
            fVar2.b(j10);
            s(fVar2, 6);
            cVar = (c) this.f7306d[7].get("PreviewImageStart");
            cVar2 = (c) this.f7306d[7].get("PreviewImageLength");
            if (cVar != null) {
                this.f7306d[5].put("JPEGInterchangeFormat", cVar);
                this.f7306d[5].put("JPEGInterchangeFormatLength", cVar2);
            }
            cVar3 = (c) this.f7306d[8].get("AspectFrame");
            if (cVar3 == null) {
            }
        }
    }

    public final void h(b bVar) {
        if (f7288l) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.f7275r = ByteOrder.BIG_ENDIAN;
        byte[] bArr = f7297u;
        bVar.a(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = bVar.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int i11 = i10 + 4;
                    if (i11 == 16 && !Arrays.equals(bArr2, f7299w)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (!Arrays.equals(bArr2, f7300x)) {
                        if (Arrays.equals(bArr2, f7298v)) {
                            byte[] bArr3 = new byte[readInt];
                            if (bVar.read(bArr3) == readInt) {
                                int readInt2 = bVar.readInt();
                                CRC32 crc32 = new CRC32();
                                crc32.update(bArr2);
                                crc32.update(bArr3);
                                if (((int) crc32.getValue()) == readInt2) {
                                    this.f7310h = i11;
                                    r(0, bArr3);
                                    x();
                                    u(new b(bArr3));
                                    return;
                                }
                                throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                            }
                            throw new IOException("Failed to read given length for given PNG chunk type: " + p9.e.D(bArr2));
                        }
                        int i12 = readInt + 4;
                        bVar.a(i12);
                        length = i11 + i12;
                    } else {
                        return;
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void i(b bVar) {
        boolean z9 = f7288l;
        if (z9) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + bVar);
        }
        bVar.a(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        byte[] bArr3 = new byte[4];
        bVar.read(bArr);
        bVar.read(bArr2);
        bVar.read(bArr3);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        int i12 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i11];
        bVar.a(i10 - bVar.f7276s);
        bVar.read(bArr4);
        e(new b(bArr4), i10, 5);
        bVar.a(i12 - bVar.f7276s);
        bVar.f7275r = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (z9) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i13 = 0; i13 < readInt; i13++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == E.f7282a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c d2 = c.d(readShort, this.f7308f);
                c d4 = c.d(readShort2, this.f7308f);
                this.f7306d[0].put("ImageLength", d2);
                this.f7306d[0].put("ImageWidth", d4);
                if (f7288l) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.a(readUnsignedShort2);
        }
    }

    public final void j(f fVar) {
        c cVar;
        o(fVar);
        s(fVar, 0);
        w(fVar, 0);
        w(fVar, 5);
        w(fVar, 4);
        x();
        if (this.f7305c == 8 && (cVar = (c) this.f7306d[1].get("MakerNote")) != null) {
            f fVar2 = new f(cVar.f7281d);
            fVar2.f7275r = this.f7308f;
            fVar2.a(6);
            s(fVar2, 9);
            c cVar2 = (c) this.f7306d[9].get("ColorSpace");
            if (cVar2 != null) {
                this.f7306d[1].put("ColorSpace", cVar2);
            }
        }
    }

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

    public final void l(b bVar) {
        if (f7288l) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.f7275r = ByteOrder.LITTLE_ENDIAN;
        bVar.a(f7301y.length);
        int readInt = bVar.readInt() + 8;
        byte[] bArr = f7302z;
        bVar.a(bArr.length);
        int length = bArr.length + 8;
        while (true) {
            try {
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int readInt2 = bVar.readInt();
                    int i10 = length + 4 + 4;
                    if (Arrays.equals(A, bArr2)) {
                        byte[] bArr3 = new byte[readInt2];
                        if (bVar.read(bArr3) == readInt2) {
                            this.f7310h = i10;
                            r(0, bArr3);
                            u(new b(bArr3));
                            return;
                        }
                        throw new IOException("Failed to read given length for given PNG chunk type: " + p9.e.D(bArr2));
                    }
                    if (readInt2 % 2 == 1) {
                        readInt2++;
                    }
                    length = i10 + readInt2;
                    if (length == readInt) {
                        return;
                    }
                    if (length <= readInt) {
                        bVar.a(readInt2);
                    } else {
                        throw new IOException("Encountered WebP file with invalid chunk size");
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void m(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int f10 = cVar.f(this.f7308f);
        int f11 = cVar2.f(this.f7308f);
        if (this.f7305c == 7) {
            f10 += this.f7311i;
        }
        if (f10 > 0 && f11 > 0 && this.f7304b == null && this.f7303a == null) {
            bVar.skip(f10);
            bVar.read(new byte[f11]);
        }
        if (f7288l) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + f10 + ", length: " + f11);
        }
    }

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

    public final void o(b bVar) {
        ByteOrder q9 = q(bVar);
        this.f7308f = q9;
        bVar.f7275r = q9;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i10 = this.f7305c;
        if (i10 != 7 && i10 != 10 && readUnsignedShort != 42) {
            StringBuilder s9 = a.g.s("Invalid start code: ");
            s9.append(Integer.toHexString(readUnsignedShort));
            throw new IOException(s9.toString());
        }
        int readInt = bVar.readInt();
        if (readInt >= 8) {
            int i11 = readInt - 8;
            if (i11 > 0) {
                bVar.a(i11);
                return;
            }
            return;
        }
        throw new IOException(o.u("Invalid first Ifd offset: ", readInt));
    }

    public final void p() {
        for (int i10 = 0; i10 < this.f7306d.length; i10++) {
            StringBuilder t9 = a.g.t("The size of tag group[", i10, "]: ");
            t9.append(this.f7306d[i10].size());
            Log.d("ExifInterface", t9.toString());
            for (Map.Entry entry : this.f7306d[i10].entrySet()) {
                c cVar = (c) entry.getValue();
                StringBuilder s9 = a.g.s("tagName: ");
                s9.append((String) entry.getKey());
                s9.append(", tagType: ");
                s9.append(cVar.toString());
                s9.append(", tagValue: '");
                s9.append(cVar.g(this.f7308f));
                s9.append("'");
                Log.d("ExifInterface", s9.toString());
            }
        }
    }

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

    public final void s(f fVar, int i10) {
        StringBuilder sb;
        String str;
        short s9;
        short s10;
        int[] iArr;
        boolean z9;
        long j10;
        boolean z10;
        int i11;
        long j11;
        d dVar;
        long j12;
        int readUnsignedShort;
        StringBuilder sb2;
        String str2;
        int i12 = i10;
        this.f7307e.add(Integer.valueOf(fVar.f7276s));
        short readShort = fVar.readShort();
        if (f7288l) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (readShort <= 0) {
            return;
        }
        char c10 = 0;
        short s11 = 0;
        while (s11 < readShort) {
            int readUnsignedShort2 = fVar.readUnsignedShort();
            int readUnsignedShort3 = fVar.readUnsignedShort();
            int readInt = fVar.readInt();
            long j13 = fVar.f7276s + 4;
            d dVar2 = (d) H[i12].get(Integer.valueOf(readUnsignedShort2));
            boolean z11 = f7288l;
            if (z11) {
                Object[] objArr = new Object[5];
                objArr[c10] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                if (dVar2 != null) {
                    str2 = dVar2.f7283b;
                } else {
                    str2 = null;
                }
                objArr[2] = str2;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d("ExifInterface", String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            }
            if (dVar2 == null) {
                if (z11) {
                    Log.d("ExifInterface", "Skip the tag entry since tag number is not defined: " + readUnsignedShort2);
                }
                s9 = readShort;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < C.length) {
                        int i13 = dVar2.f7284c;
                        if (i13 != 7 && readUnsignedShort3 != 7 && i13 != readUnsignedShort3 && (i11 = dVar2.f7285d) != readUnsignedShort3) {
                            s9 = readShort;
                            if (((i13 != 4 && i11 != 4) || readUnsignedShort3 != 3) && (((i13 != 9 && i11 != 9) || readUnsignedShort3 != 8) && ((i13 != 12 && i11 != 12) || readUnsignedShort3 != 11))) {
                                z9 = false;
                                if (z9) {
                                    if (z11) {
                                        StringBuilder s12 = a.g.s("Skip the tag entry since data format (");
                                        s12.append(B[readUnsignedShort3]);
                                        s12.append(") is unexpected for tag: ");
                                        s12.append(dVar2.f7283b);
                                        Log.d("ExifInterface", s12.toString());
                                    }
                                } else {
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i13;
                                    }
                                    s10 = s11;
                                    j10 = iArr[readUnsignedShort3] * readInt;
                                    if (j10 >= 0 && j10 <= 2147483647L) {
                                        z10 = true;
                                        if (z10) {
                                        }
                                        s11 = (short) (s10 + 1);
                                        c10 = 0;
                                        i12 = i10;
                                        readShort = s9;
                                    } else {
                                        if (z11) {
                                            Log.d("ExifInterface", "Skip the tag entry since the number of components is invalid: " + readInt);
                                        }
                                        z10 = false;
                                        if (z10) {
                                            fVar.b(j13);
                                        } else {
                                            if (j10 > 4) {
                                                int readInt2 = fVar.readInt();
                                                if (z11) {
                                                    StringBuilder sb3 = new StringBuilder();
                                                    j11 = j13;
                                                    sb3.append("seek to data offset: ");
                                                    sb3.append(readInt2);
                                                    Log.d("ExifInterface", sb3.toString());
                                                } else {
                                                    j11 = j13;
                                                }
                                                if (this.f7305c == 7) {
                                                    if ("MakerNote".equals(dVar2.f7283b)) {
                                                        this.f7311i = readInt2;
                                                    } else if (i12 == 6 && "ThumbnailImage".equals(dVar2.f7283b)) {
                                                        this.f7312j = readInt2;
                                                        this.f7313k = readInt;
                                                        c d2 = c.d(6, this.f7308f);
                                                        dVar = dVar2;
                                                        c b3 = c.b(this.f7312j, this.f7308f);
                                                        c b10 = c.b(this.f7313k, this.f7308f);
                                                        this.f7306d[4].put("Compression", d2);
                                                        this.f7306d[4].put("JPEGInterchangeFormat", b3);
                                                        this.f7306d[4].put("JPEGInterchangeFormatLength", b10);
                                                        fVar.b(readInt2);
                                                    }
                                                }
                                                dVar = dVar2;
                                                fVar.b(readInt2);
                                            } else {
                                                j11 = j13;
                                                dVar = dVar2;
                                            }
                                            Integer num = (Integer) K.get(Integer.valueOf(readUnsignedShort2));
                                            if (z11) {
                                                Log.d("ExifInterface", "nextIfdType: " + num + " byteCount: " + j10);
                                            }
                                            if (num != null) {
                                                long j14 = -1;
                                                if (readUnsignedShort3 != 3) {
                                                    if (readUnsignedShort3 != 4) {
                                                        if (readUnsignedShort3 != 8) {
                                                            if (readUnsignedShort3 == 9 || readUnsignedShort3 == 13) {
                                                                readUnsignedShort = fVar.readInt();
                                                            }
                                                        } else {
                                                            readUnsignedShort = fVar.readShort();
                                                        }
                                                    } else {
                                                        j14 = fVar.readInt() & 4294967295L;
                                                    }
                                                    if (z11) {
                                                        Log.d("ExifInterface", String.format("Offset: %d, tagName: %s", Long.valueOf(j14), dVar.f7283b));
                                                    }
                                                    if (j14 <= 0) {
                                                        if (!this.f7307e.contains(Integer.valueOf((int) j14))) {
                                                            fVar.b(j14);
                                                            s(fVar, num.intValue());
                                                        } else if (z11) {
                                                            sb2 = new StringBuilder();
                                                            sb2.append("Skip jump into the IFD since it has already been read: IfdType ");
                                                            sb2.append(num);
                                                            sb2.append(" (at ");
                                                            sb2.append(j14);
                                                            sb2.append(")");
                                                            Log.d("ExifInterface", sb2.toString());
                                                        }
                                                        j12 = j11;
                                                    } else {
                                                        if (z11) {
                                                            sb2 = new StringBuilder();
                                                            sb2.append("Skip jump into the IFD since its offset is invalid: ");
                                                            sb2.append(j14);
                                                            Log.d("ExifInterface", sb2.toString());
                                                        }
                                                        j12 = j11;
                                                    }
                                                } else {
                                                    readUnsignedShort = fVar.readUnsignedShort();
                                                }
                                                j14 = readUnsignedShort;
                                                if (z11) {
                                                }
                                                if (j14 <= 0) {
                                                }
                                            } else {
                                                d dVar3 = dVar;
                                                int i14 = fVar.f7276s + this.f7310h;
                                                byte[] bArr = new byte[(int) j10];
                                                fVar.readFully(bArr);
                                                j12 = j11;
                                                c cVar = new c(i14, bArr, readUnsignedShort3, readInt);
                                                this.f7306d[i10].put(dVar3.f7283b, cVar);
                                                if ("DNGVersion".equals(dVar3.f7283b)) {
                                                    this.f7305c = 3;
                                                }
                                                if ((("Make".equals(dVar3.f7283b) || "Model".equals(dVar3.f7283b)) && cVar.g(this.f7308f).contains("PENTAX")) || ("Compression".equals(dVar3.f7283b) && cVar.f(this.f7308f) == 65535)) {
                                                    this.f7305c = 8;
                                                }
                                                if (fVar.f7276s == j12) {
                                                }
                                            }
                                            fVar.b(j12);
                                        }
                                        s11 = (short) (s10 + 1);
                                        c10 = 0;
                                        i12 = i10;
                                        readShort = s9;
                                    }
                                }
                            }
                        } else {
                            s9 = readShort;
                        }
                        z9 = true;
                        if (z9) {
                        }
                    }
                }
                s9 = readShort;
                s10 = s11;
                if (z11) {
                    Log.d("ExifInterface", "Skip the tag entry since data format is invalid: " + readUnsignedShort3);
                }
                j10 = 0;
                z10 = false;
                if (z10) {
                }
                s11 = (short) (s10 + 1);
                c10 = 0;
                i12 = i10;
                readShort = s9;
            }
            s10 = s11;
            j10 = 0;
            z10 = false;
            if (z10) {
            }
            s11 = (short) (s10 + 1);
            c10 = 0;
            i12 = i10;
            readShort = s9;
        }
        int readInt3 = fVar.readInt();
        boolean z12 = f7288l;
        if (z12) {
            Log.d("ExifInterface", String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
        }
        long j15 = readInt3;
        if (j15 > 0) {
            if (!this.f7307e.contains(Integer.valueOf(readInt3))) {
                fVar.b(j15);
                if (this.f7306d[4].isEmpty()) {
                    s(fVar, 4);
                    return;
                } else if (this.f7306d[5].isEmpty()) {
                    s(fVar, 5);
                    return;
                } else {
                    return;
                }
            } else if (z12) {
                sb = new StringBuilder();
                str = "Stop reading file since re-reading an IFD may cause an infinite loop: ";
            } else {
                return;
            }
        } else if (z12) {
            sb = new StringBuilder();
            str = "Stop reading file since a wrong offset may cause an infinite loop: ";
        } else {
            return;
        }
        sb.append(str);
        sb.append(readInt3);
        Log.d("ExifInterface", sb.toString());
    }

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

    public final void u(b bVar) {
        boolean z9;
        String str;
        String str2;
        StringBuilder sb;
        c cVar;
        int f10;
        HashMap hashMap = this.f7306d[4];
        c cVar2 = (c) hashMap.get("Compression");
        if (cVar2 != null) {
            int f11 = cVar2.f(this.f7308f);
            if (f11 != 1) {
                if (f11 != 6) {
                    if (f11 != 7) {
                        return;
                    }
                }
            }
            c cVar3 = (c) hashMap.get("BitsPerSample");
            if (cVar3 != null) {
                int[] iArr = (int[]) cVar3.h(this.f7308f);
                int[] iArr2 = f7289m;
                if (Arrays.equals(iArr2, iArr) || (this.f7305c == 3 && (cVar = (c) hashMap.get("PhotometricInterpretation")) != null && (((f10 = cVar.f(this.f7308f)) == 1 && Arrays.equals(iArr, f7290n)) || (f10 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z9 = true;
                    if (!z9) {
                        c cVar4 = (c) hashMap.get("StripOffsets");
                        c cVar5 = (c) hashMap.get("StripByteCounts");
                        if (cVar4 != null && cVar5 != null) {
                            long[] J2 = p9.e.J(cVar4.h(this.f7308f));
                            long[] J3 = p9.e.J(cVar5.h(this.f7308f));
                            if (J2 != null && J2.length != 0) {
                                if (J3 != null && J3.length != 0) {
                                    if (J2.length != J3.length) {
                                        str = "stripOffsets and stripByteCounts should have same length.";
                                    } else {
                                        long j10 = 0;
                                        for (long j11 : J3) {
                                            j10 += j11;
                                        }
                                        byte[] bArr = new byte[(int) j10];
                                        this.f7309g = true;
                                        int i10 = 0;
                                        int i11 = 0;
                                        for (int i12 = 0; i12 < J2.length; i12++) {
                                            int i13 = (int) J2[i12];
                                            int i14 = (int) J3[i12];
                                            if (i12 < J2.length - 1 && i13 + i14 != J2[i12 + 1]) {
                                                this.f7309g = false;
                                            }
                                            int i15 = i13 - i10;
                                            if (i15 < 0) {
                                                str2 = "Invalid strip offset value";
                                            } else {
                                                long j12 = i15;
                                                if (bVar.skip(j12) != j12) {
                                                    sb = new StringBuilder();
                                                    sb.append("Failed to skip ");
                                                    sb.append(i15);
                                                } else {
                                                    int i16 = i10 + i15;
                                                    byte[] bArr2 = new byte[i14];
                                                    if (bVar.read(bArr2) != i14) {
                                                        sb = new StringBuilder();
                                                        sb.append("Failed to read ");
                                                        sb.append(i14);
                                                    } else {
                                                        i10 = i16 + i14;
                                                        System.arraycopy(bArr2, 0, bArr, i11, i14);
                                                        i11 += i14;
                                                    }
                                                }
                                                sb.append(" bytes.");
                                                str2 = sb.toString();
                                            }
                                            Log.d("ExifInterface", str2);
                                            return;
                                        }
                                        if (this.f7309g) {
                                            long j13 = J2[0];
                                            return;
                                        }
                                        return;
                                    }
                                } else {
                                    str = "stripByteCounts should not be null or have zero length.";
                                }
                            } else {
                                str = "stripOffsets should not be null or have zero length.";
                            }
                            Log.w("ExifInterface", str);
                            return;
                        }
                        return;
                    }
                    return;
                }
            }
            if (f7288l) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z9 = false;
            if (!z9) {
            }
        }
        m(bVar, hashMap);
    }

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

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

    public final void x() {
        v(0, 5);
        v(0, 4);
        v(5, 4);
        c cVar = (c) this.f7306d[1].get("PixelXDimension");
        c cVar2 = (c) this.f7306d[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            this.f7306d[0].put("ImageWidth", cVar);
            this.f7306d[0].put("ImageLength", cVar2);
        }
        if (this.f7306d[4].isEmpty() && n(this.f7306d[5])) {
            HashMap[] hashMapArr = this.f7306d;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap();
        }
        if (!n(this.f7306d[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");
    }
}