米游社.apk(点击下载) / a.java


package w1;

import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
import androidx.media.AudioAttributesCompat;
import com.google.common.base.Ascii;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView;
import e.m0;
import e.o0;
import e.x0;
import f1.k;
import j$.util.DesugarTimeZone;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.CRC32;

/* compiled from: ExifInterface */
public class a {
    public static final String A = "ImageLength";
    @Deprecated
    public static final String A0 = "ISOSpeedRatings";
    public static final String A1 = "GPSLatitudeRef";
    public static final String A2 = "InteroperabilityIFDPointer";
    public static final short A3 = 3;
    public static final short A4 = 0;
    public static final int A5 = 0;
    public static final int A6 = 6;
    public static final byte A7 = -54;
    public static final String B = "BitsPerSample";
    public static final String B0 = "PhotographicSensitivity";
    public static final String B1 = "GPSLatitude";
    public static final String B2 = "SubIFDPointer";
    public static final short B3 = 4;
    public static final short B4 = 1;
    public static final int B5 = 1;
    public static final int B6 = 7;
    public static final byte B7 = -53;
    public static final String C = "Compression";
    public static final String C0 = "OECF";
    public static final String C1 = "GPSLongitudeRef";
    public static final String C2 = "CameraSettingsIFDPointer";
    public static final short C3 = 9;
    public static final short C4 = 2;
    public static final int C5 = 0;
    public static final int C6 = 8;
    public static final byte C7 = -51;
    public static final String D = "PhotometricInterpretation";
    public static final String D0 = "SensitivityType";
    public static final String D1 = "GPSLongitude";
    public static final String D2 = "ImageProcessingIFDPointer";
    public static final short D3 = 10;
    public static final short D4 = 3;
    public static final int D5 = 1;
    public static final int D6 = 9;
    public static final byte D7 = -50;
    public static final String E = "Orientation";
    public static final String E0 = "StandardOutputSensitivity";
    public static final String E1 = "GPSAltitudeRef";
    public static final int E2 = 512;
    public static final short E3 = 11;
    public static final short E4 = 4;
    public static final int E5 = 5000;
    public static final int E6 = 10;
    public static final byte E7 = -49;
    public static final String F = "SamplesPerPixel";
    public static final String F0 = "RecommendedExposureIndex";
    public static final String F1 = "GPSAltitude";
    public static final int F2 = 0;
    public static final short F3 = 12;
    public static final short F4 = 0;
    public static final byte[] F5 = {-1, f146746r7, -1};
    public static final int F6 = 11;
    public static final byte F7 = -38;
    public static final String G = "PlanarConfiguration";
    public static final String G0 = "ISOSpeed";
    public static final String G1 = "GPSTimeStamp";
    public static final int G2 = 1;
    public static final short G3 = 13;
    public static final short G4 = 1;
    public static final String G5 = "FUJIFILMCCD-RAW";
    public static final int G6 = 12;
    public static final byte G7 = -31;
    public static final String H = "YCbCrSubSampling";
    public static final String H0 = "ISOSpeedLatitudeyyy";
    public static final String H1 = "GPSSatellites";
    public static final int H2 = 2;
    public static final short H3 = 14;
    public static final short H4 = 2;
    public static final int H5 = 84;
    public static final int H6 = 13;
    public static final byte H7 = -2;
    public static final String I = "YCbCrPositioning";
    public static final String I0 = "ISOSpeedLatitudezzz";
    public static final String I1 = "GPSStatus";
    public static final int I2 = 3;
    public static final short I3 = 15;
    public static final short I4 = 0;
    public static final int I5 = 4;
    public static final String[] I6 = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    public static final byte I7 = -39;
    public static final String J = "XResolution";
    public static final String J0 = "ShutterSpeedValue";
    public static final String J1 = "GPSMeasureMode";
    public static final int J2 = 4;
    public static final short J3 = 16;
    public static final short J4 = 0;
    public static final byte[] J5 = {102, 116, 121, 112};
    public static final int[] J6 = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    public static final int J7 = 0;
    public static final String K = "YResolution";
    public static final String K0 = "ApertureValue";
    public static final String K1 = "GPSDOP";
    public static final int K2 = 5;
    public static final short K3 = 17;
    public static final short K4 = 0;
    public static final byte[] K5 = {109, 105, 102, 49};
    public static final byte[] K6 = {65, 83, 67, 73, 73, 0, 0, 0};
    public static final int K7 = 1;
    public static final String L = "ResolutionUnit";
    public static final String L0 = "BrightnessValue";
    public static final String L1 = "GPSSpeedRef";
    public static final int L2 = 6;
    public static final short L3 = 18;
    public static final short L4 = 0;
    public static final byte[] L5 = {104, 101, 105, 99};
    public static final f[] L6;
    public static final int L7 = 2;
    public static final String M = "StripOffsets";
    public static final String M0 = "ExposureBiasValue";
    public static final String M1 = "GPSSpeed";
    public static final int M2 = 7;
    public static final short M3 = 19;
    public static final short M4 = 1;
    public static final short M5 = 20306;
    public static final f[] M6;
    public static final int M7 = 3;
    public static final String N = "RowsPerStrip";
    public static final String N0 = "MaxApertureValue";
    public static final String N1 = "GPSTrackRef";
    public static final int N2 = 8;
    public static final short N3 = 20;
    public static final short N4 = 2;
    public static final short N5 = 21330;
    public static final f[] N6;
    public static final int N7 = 4;
    public static final String O = "StripByteCounts";
    public static final String O0 = "SubjectDistance";
    public static final String O1 = "GPSTrack";
    public static final List<Integer> O2 = Arrays.asList(1, 6, 3, 8);
    public static final short O3 = 21;
    public static final short O4 = 0;
    public static final byte[] O5 = {79, 76, 89, 77, 80, 0};
    public static final f[] O6;
    public static final int O7 = 5;
    public static final String P = "JPEGInterchangeFormat";
    public static final String P0 = "MeteringMode";
    public static final String P1 = "GPSImgDirectionRef";
    public static final List<Integer> P2 = Arrays.asList(2, 7, 4, 5);
    public static final short P3 = 22;
    public static final short P4 = 1;
    public static final byte[] P5 = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final f[] P6;
    public static final int P7 = 6;
    public static final String Q = "JPEGInterchangeFormatLength";
    public static final String Q0 = "LightSource";
    public static final String Q1 = "GPSImgDirection";
    public static final short Q2 = 1;
    public static final short Q3 = 23;
    public static final short Q4 = 2;
    public static final int Q5 = 8;
    public static final f Q6 = new f(M, AudioAttributesCompat.O, 3);
    public static final int Q7 = 7;
    public static final String R = "TransferFunction";
    public static final String R0 = "Flash";
    public static final String R1 = "GPSMapDatum";
    public static final short R2 = 2;
    public static final short R3 = 24;
    public static final short R4 = 3;
    public static final int R5 = 12;
    public static final f[] R6;
    public static final int R7 = 8;
    public static final String S = "WhitePoint";
    public static final String S0 = "SubjectArea";
    public static final String S1 = "GPSDestLatitudeRef";
    public static final short S2 = 1;
    public static final short S3 = 255;
    public static final String S4 = "N";
    public static final short S5 = 85;
    public static final f[] S6;
    public static final int S7 = 9;
    public static final String T = "PrimaryChromaticities";
    public static final String T0 = "FocalLength";
    public static final String T1 = "GPSDestLatitude";
    public static final short T2 = 2;
    public static final short T3 = 1;
    public static final String T4 = "S";
    public static final String T5 = "PENTAX";
    public static final f[] T6;
    public static final int T7 = 10;
    public static final String U = "YCbCrCoefficients";
    public static final String U0 = "FlashEnergy";
    public static final String U1 = "GPSDestLongitudeRef";
    public static final short U2 = 2;
    public static final short U3 = 4;
    public static final String U4 = "E";
    public static final int U5 = 6;
    public static final f[] U6;
    public static final int U7 = 11;
    public static final String V = "ReferenceBlackWhite";
    public static final String V0 = "SpatialFrequencyResponse";
    public static final String V1 = "GPSDestLongitude";
    public static final short V2 = 3;
    public static final short V3 = 6;
    public static final String V4 = "W";
    public static final byte[] V5 = {-119, 80, 78, 71, 13, 10, Ascii.SUB, 10};
    public static final int V6 = 0;
    public static final int V7 = 12;
    public static final String W = "DateTime";
    public static final String W0 = "FocalPlaneXResolution";
    public static final String W1 = "GPSDestBearingRef";
    public static final int W2 = 1;
    public static final short W3 = 8;
    public static final short W4 = 0;
    public static final byte[] W5 = {101, 88, 73, 102};
    public static final int W6 = 1;
    public static final int W7 = 13;
    public static final String X = "ImageDescription";
    public static final String X0 = "FocalPlaneYResolution";
    public static final String X1 = "GPSDestBearing";
    public static final int X2 = 65535;
    public static final short X3 = 16;
    public static final short X4 = 1;
    public static final byte[] X5 = {73, 72, 68, 82};
    public static final int X6 = 2;
    public static final int X7 = 14;
    public static final String Y = "Make";
    public static final String Y0 = "FocalPlaneResolutionUnit";
    public static final String Y1 = "GPSDestDistanceRef";
    public static final short Y2 = 0;
    public static final short Y3 = 24;
    public static final String Y4 = "A";
    public static final byte[] Y5 = {73, 69, 78, 68};
    public static final int Y6 = 3;
    public static final Pattern Y7 = Pattern.compile(".*[1-9].*");
    public static final String Z = "Model";
    public static final String Z0 = "SubjectLocation";
    public static final String Z1 = "GPSDestDistance";
    public static final short Z2 = 1;
    public static final short Z3 = 32;
    public static final String Z4 = "V";
    public static final int Z5 = 4;
    public static final int Z6 = 4;
    public static final Pattern Z7 = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");

    /* renamed from: a0  reason: collision with root package name */
    public static final String f146603a0 = "Software";

    /* renamed from: a1  reason: collision with root package name */
    public static final String f146604a1 = "ExposureIndex";

    /* renamed from: a2  reason: collision with root package name */
    public static final String f146605a2 = "GPSProcessingMethod";

    /* renamed from: a3  reason: collision with root package name */
    public static final short f146606a3 = 2;

    /* renamed from: a4  reason: collision with root package name */
    public static final short f146607a4 = 64;

    /* renamed from: a5  reason: collision with root package name */
    public static final String f146608a5 = "2";

    /* renamed from: a6  reason: collision with root package name */
    public static final int f146609a6 = 4;

    /* renamed from: a7  reason: collision with root package name */
    public static final int f146610a7 = 5;

    /* renamed from: b0  reason: collision with root package name */
    public static final String f146611b0 = "Artist";

    /* renamed from: b1  reason: collision with root package name */
    public static final String f146612b1 = "SensingMethod";

    /* renamed from: b2  reason: collision with root package name */
    public static final String f146613b2 = "GPSAreaInformation";

    /* renamed from: b3  reason: collision with root package name */
    public static final short f146614b3 = 3;

    /* renamed from: b4  reason: collision with root package name */
    public static final short f146615b4 = 1;

    /* renamed from: b5  reason: collision with root package name */
    public static final String f146616b5 = "3";

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

    /* renamed from: b7  reason: collision with root package name */
    public static final int f146618b7 = 6;

    /* renamed from: c0  reason: collision with root package name */
    public static final String f146619c0 = "Copyright";

    /* renamed from: c1  reason: collision with root package name */
    public static final String f146620c1 = "FileSource";

    /* renamed from: c2  reason: collision with root package name */
    public static final String f146621c2 = "GPSDateStamp";

    /* renamed from: c3  reason: collision with root package name */
    public static final short f146622c3 = 4;

    /* renamed from: c4  reason: collision with root package name */
    public static final short f146623c4 = 2;

    /* renamed from: c5  reason: collision with root package name */
    public static final String f146624c5 = "K";

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

    /* renamed from: c7  reason: collision with root package name */
    public static final int f146626c7 = 7;

    /* renamed from: d0  reason: collision with root package name */
    public static final String f146627d0 = "ExifVersion";

    /* renamed from: d1  reason: collision with root package name */
    public static final String f146628d1 = "SceneType";

    /* renamed from: d2  reason: collision with root package name */
    public static final String f146629d2 = "GPSDifferential";

    /* renamed from: d3  reason: collision with root package name */
    public static final short f146630d3 = 5;

    /* renamed from: d4  reason: collision with root package name */
    public static final short f146631d4 = 3;

    /* renamed from: d5  reason: collision with root package name */
    public static final String f146632d5 = "M";

    /* renamed from: d6  reason: collision with root package name */
    public static final int f146633d6 = 4;

    /* renamed from: d7  reason: collision with root package name */
    public static final int f146634d7 = 8;

    /* renamed from: e0  reason: collision with root package name */
    public static final String f146635e0 = "FlashpixVersion";

    /* renamed from: e1  reason: collision with root package name */
    public static final String f146636e1 = "CFAPattern";

    /* renamed from: e2  reason: collision with root package name */
    public static final String f146637e2 = "GPSHPositioningError";

    /* renamed from: e3  reason: collision with root package name */
    public static final short f146638e3 = 6;

    /* renamed from: e4  reason: collision with root package name */
    public static final short f146639e4 = 4;

    /* renamed from: e5  reason: collision with root package name */
    public static final String f146640e5 = "N";

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

    /* renamed from: e7  reason: collision with root package name */
    public static final int f146642e7 = 9;

    /* renamed from: f0  reason: collision with root package name */
    public static final String f146643f0 = "ColorSpace";

    /* renamed from: f1  reason: collision with root package name */
    public static final String f146644f1 = "CustomRendered";

    /* renamed from: f2  reason: collision with root package name */
    public static final String f146645f2 = "InteroperabilityIndex";

    /* renamed from: f3  reason: collision with root package name */
    public static final short f146646f3 = 7;

    /* renamed from: f4  reason: collision with root package name */
    public static final short f146647f4 = 5;

    /* renamed from: f5  reason: collision with root package name */
    public static final String f146648f5 = "T";

    /* renamed from: f6  reason: collision with root package name */
    public static final byte[] f146649f6 = {-99, 1, f146761t6};

    /* renamed from: f7  reason: collision with root package name */
    public static final f[][] f146650f7;

    /* renamed from: g0  reason: collision with root package name */
    public static final String f146651g0 = "Gamma";

    /* renamed from: g1  reason: collision with root package name */
    public static final String f146652g1 = "ExposureMode";

    /* renamed from: g2  reason: collision with root package name */
    public static final String f146653g2 = "ThumbnailImageLength";

    /* renamed from: g3  reason: collision with root package name */
    public static final short f146654g3 = 8;

    /* renamed from: g4  reason: collision with root package name */
    public static final short f146655g4 = 7;

    /* renamed from: g5  reason: collision with root package name */
    public static final String f146656g5 = "M";

    /* renamed from: g6  reason: collision with root package name */
    public static final byte f146657g6 = 47;

    /* renamed from: g7  reason: collision with root package name */
    public static final f[] f146658g7 = {new f(B2, 330, 4), new f(f146799y2, 34665, 4), new f(f146808z2, 34853, 4), new f(A2, 40965, 4), new f(C2, 8224, 1), new f(D2, 8256, 1)};

    /* renamed from: h0  reason: collision with root package name */
    public static final String f146659h0 = "PixelXDimension";

    /* renamed from: h1  reason: collision with root package name */
    public static final String f146660h1 = "WhiteBalance";

    /* renamed from: h2  reason: collision with root package name */
    public static final String f146661h2 = "ThumbnailImageWidth";

    /* renamed from: h3  reason: collision with root package name */
    public static final short f146662h3 = 0;

    /* renamed from: h4  reason: collision with root package name */
    public static final short f146663h4 = 8;

    /* renamed from: h5  reason: collision with root package name */
    public static final String f146664h5 = "K";

    /* renamed from: h6  reason: collision with root package name */
    public static final byte[] f146665h6 = "VP8X".getBytes(Charset.defaultCharset());

    /* renamed from: h7  reason: collision with root package name */
    public static final f f146666h7 = new f(P, k.f58634j, 4);

    /* renamed from: i0  reason: collision with root package name */
    public static final String f146667i0 = "PixelYDimension";

    /* renamed from: i1  reason: collision with root package name */
    public static final String f146668i1 = "DigitalZoomRatio";
    @x0({x0.a.LIBRARY})

    /* renamed from: i2  reason: collision with root package name */
    public static final String f146669i2 = "ThumbnailOrientation";

    /* renamed from: i3  reason: collision with root package name */
    public static final short f146670i3 = 1;

    /* renamed from: i4  reason: collision with root package name */
    public static final short f146671i4 = 0;

    /* renamed from: i5  reason: collision with root package name */
    public static final String f146672i5 = "M";

    /* renamed from: i6  reason: collision with root package name */
    public static final byte[] f146673i6 = "VP8L".getBytes(Charset.defaultCharset());

    /* renamed from: i7  reason: collision with root package name */
    public static final f f146674i7 = new f(Q, 514, 4);

    /* renamed from: j0  reason: collision with root package name */
    public static final String f146675j0 = "ComponentsConfiguration";

    /* renamed from: j1  reason: collision with root package name */
    public static final String f146676j1 = "FocalLengthIn35mmFilm";

    /* renamed from: j2  reason: collision with root package name */
    public static final String f146677j2 = "DNGVersion";

    /* renamed from: j3  reason: collision with root package name */
    public static final short f146678j3 = 2;

    /* renamed from: j4  reason: collision with root package name */
    public static final short f146679j4 = 1;

    /* renamed from: j5  reason: collision with root package name */
    public static final String f146680j5 = "N";

    /* renamed from: j6  reason: collision with root package name */
    public static final byte[] f146681j6 = "VP8 ".getBytes(Charset.defaultCharset());

    /* renamed from: j7  reason: collision with root package name */
    public static final HashMap<Integer, f>[] f146682j7;

    /* renamed from: k0  reason: collision with root package name */
    public static final String f146683k0 = "CompressedBitsPerPixel";

    /* renamed from: k1  reason: collision with root package name */
    public static final String f146684k1 = "SceneCaptureType";

    /* renamed from: k2  reason: collision with root package name */
    public static final String f146685k2 = "DefaultCropSize";

    /* renamed from: k3  reason: collision with root package name */
    public static final short f146686k3 = 3;

    /* renamed from: k4  reason: collision with root package name */
    public static final short f146687k4 = 2;

    /* renamed from: k5  reason: collision with root package name */
    public static final short f146688k5 = 0;

    /* renamed from: k6  reason: collision with root package name */
    public static final byte[] f146689k6 = "ANIM".getBytes(Charset.defaultCharset());

    /* renamed from: k7  reason: collision with root package name */
    public static final HashMap<String, f>[] f146690k7;

    /* renamed from: l0  reason: collision with root package name */
    public static final String f146691l0 = "MakerNote";

    /* renamed from: l1  reason: collision with root package name */
    public static final String f146692l1 = "GainControl";

    /* renamed from: l2  reason: collision with root package name */
    public static final String f146693l2 = "ThumbnailImage";

    /* renamed from: l3  reason: collision with root package name */
    public static final short f146694l3 = 4;

    /* renamed from: l4  reason: collision with root package name */
    public static final short f146695l4 = 3;

    /* renamed from: l5  reason: collision with root package name */
    public static final short f146696l5 = 1;

    /* renamed from: l6  reason: collision with root package name */
    public static final byte[] f146697l6 = "ANMF".getBytes(Charset.defaultCharset());

    /* renamed from: l7  reason: collision with root package name */
    public static final HashSet<String> f146698l7 = new HashSet<>(Arrays.asList(f146788x0, f146668i1, f146779w0, O0, G1));

    /* renamed from: m0  reason: collision with root package name */
    public static final String f146699m0 = "UserComment";

    /* renamed from: m1  reason: collision with root package name */
    public static final String f146700m1 = "Contrast";

    /* renamed from: m2  reason: collision with root package name */
    public static final String f146701m2 = "PreviewImageStart";

    /* renamed from: m3  reason: collision with root package name */
    public static final short f146702m3 = 5;

    /* renamed from: m4  reason: collision with root package name */
    public static final short f146703m4 = 1;

    /* renamed from: m5  reason: collision with root package name */
    public static final int f146704m5 = 1;

    /* renamed from: m6  reason: collision with root package name */
    public static final byte[] f146705m6 = "XMP ".getBytes(Charset.defaultCharset());

    /* renamed from: m7  reason: collision with root package name */
    public static final HashMap<Integer, Integer> f146706m7 = new HashMap<>();

    /* renamed from: n0  reason: collision with root package name */
    public static final String f146707n0 = "RelatedSoundFile";

    /* renamed from: n1  reason: collision with root package name */
    public static final String f146708n1 = "Saturation";

    /* renamed from: n2  reason: collision with root package name */
    public static final String f146709n2 = "PreviewImageLength";

    /* renamed from: n3  reason: collision with root package name */
    public static final short f146710n3 = 6;

    /* renamed from: n4  reason: collision with root package name */
    public static final short f146711n4 = 0;

    /* renamed from: n5  reason: collision with root package name */
    public static final int f146712n5 = 2;

    /* renamed from: n6  reason: collision with root package name */
    public static final int f146713n6 = 10;

    /* renamed from: n7  reason: collision with root package name */
    public static final Charset f146714n7;

    /* renamed from: o0  reason: collision with root package name */
    public static final String f146715o0 = "DateTimeOriginal";

    /* renamed from: o1  reason: collision with root package name */
    public static final String f146716o1 = "Sharpness";

    /* renamed from: o2  reason: collision with root package name */
    public static final String f146717o2 = "AspectFrame";

    /* renamed from: o3  reason: collision with root package name */
    public static final short f146718o3 = 7;

    /* renamed from: o4  reason: collision with root package name */
    public static final short f146719o4 = 1;

    /* renamed from: o5  reason: collision with root package name */
    public static final int f146720o5 = 6;

    /* renamed from: o6  reason: collision with root package name */
    public static final int f146721o6 = 4;

    /* renamed from: o7  reason: collision with root package name */
    public static final byte[] f146722o7;

    /* renamed from: p0  reason: collision with root package name */
    public static final String f146723p0 = "DateTimeDigitized";

    /* renamed from: p1  reason: collision with root package name */
    public static final String f146724p1 = "DeviceSettingDescription";

    /* renamed from: p2  reason: collision with root package name */
    public static final String f146725p2 = "SensorBottomBorder";

    /* renamed from: p3  reason: collision with root package name */
    public static final short f146726p3 = 0;

    /* renamed from: p4  reason: collision with root package name */
    public static final short f146727p4 = 0;

    /* renamed from: p5  reason: collision with root package name */
    public static final int f146728p5 = 7;

    /* renamed from: p6  reason: collision with root package name */
    public static final int f146729p6 = 4;

    /* renamed from: p7  reason: collision with root package name */
    public static final byte[] f146730p7;

    /* renamed from: q0  reason: collision with root package name */
    public static final String f146731q0 = "OffsetTime";

    /* renamed from: q1  reason: collision with root package name */
    public static final String f146732q1 = "SubjectDistanceRange";

    /* renamed from: q2  reason: collision with root package name */
    public static final String f146733q2 = "SensorLeftBorder";

    /* renamed from: q3  reason: collision with root package name */
    public static final short f146734q3 = 1;

    /* renamed from: q4  reason: collision with root package name */
    public static final short f146735q4 = 1;

    /* renamed from: q5  reason: collision with root package name */
    public static final int f146736q5 = 8;

    /* renamed from: q6  reason: collision with root package name */
    public static SimpleDateFormat f146737q6 = null;

    /* renamed from: q7  reason: collision with root package name */
    public static final byte f146738q7 = -1;

    /* renamed from: r0  reason: collision with root package name */
    public static final String f146739r0 = "OffsetTimeOriginal";

    /* renamed from: r1  reason: collision with root package name */
    public static final String f146740r1 = "ImageUniqueID";

    /* renamed from: r2  reason: collision with root package name */
    public static final String f146741r2 = "SensorRightBorder";

    /* renamed from: r3  reason: collision with root package name */
    public static final short f146742r3 = 2;

    /* renamed from: r4  reason: collision with root package name */
    public static final short f146743r4 = 2;

    /* renamed from: r5  reason: collision with root package name */
    public static final int f146744r5 = 32773;

    /* renamed from: r6  reason: collision with root package name */
    public static final short f146745r6 = 18761;

    /* renamed from: r7  reason: collision with root package name */
    public static final byte f146746r7 = -40;

    /* renamed from: s0  reason: collision with root package name */
    public static final String f146747s0 = "OffsetTimeDigitized";
    @Deprecated

    /* renamed from: s1  reason: collision with root package name */
    public static final String f146748s1 = "CameraOwnerName";

    /* renamed from: s2  reason: collision with root package name */
    public static final String f146749s2 = "SensorTopBorder";

    /* renamed from: s3  reason: collision with root package name */
    public static final short f146750s3 = 3;
    @Deprecated

    /* renamed from: s4  reason: collision with root package name */
    public static final int f146751s4 = 0;

    /* renamed from: s5  reason: collision with root package name */
    public static final int f146752s5 = 34892;

    /* renamed from: s6  reason: collision with root package name */
    public static final short f146753s6 = 19789;

    /* renamed from: s7  reason: collision with root package name */
    public static final byte f146754s7 = -64;

    /* renamed from: t0  reason: collision with root package name */
    public static final String f146755t0 = "SubSecTime";

    /* renamed from: t1  reason: collision with root package name */
    public static final String f146756t1 = "CameraOwnerName";

    /* renamed from: t2  reason: collision with root package name */
    public static final String f146757t2 = "ISO";

    /* renamed from: t3  reason: collision with root package name */
    public static final short f146758t3 = 4;
    @Deprecated

    /* renamed from: t4  reason: collision with root package name */
    public static final int f146759t4 = 1;

    /* renamed from: t5  reason: collision with root package name */
    public static final int[] f146760t5 = {8, 8, 8};

    /* renamed from: t6  reason: collision with root package name */
    public static final byte f146761t6 = 42;

    /* renamed from: t7  reason: collision with root package name */
    public static final byte f146762t7 = -63;

    /* renamed from: u0  reason: collision with root package name */
    public static final String f146763u0 = "SubSecTimeOriginal";

    /* renamed from: u1  reason: collision with root package name */
    public static final String f146764u1 = "BodySerialNumber";

    /* renamed from: u2  reason: collision with root package name */
    public static final String f146765u2 = "JpgFromRaw";

    /* renamed from: u3  reason: collision with root package name */
    public static final short f146766u3 = 5;

    /* renamed from: u4  reason: collision with root package name */
    public static final short f146767u4 = 0;

    /* renamed from: u5  reason: collision with root package name */
    public static final int[] f146768u5 = {4};

    /* renamed from: u6  reason: collision with root package name */
    public static final int f146769u6 = 8;

    /* renamed from: u7  reason: collision with root package name */
    public static final byte f146770u7 = -62;

    /* renamed from: v0  reason: collision with root package name */
    public static final String f146771v0 = "SubSecTimeDigitized";

    /* renamed from: v1  reason: collision with root package name */
    public static final String f146772v1 = "LensSpecification";

    /* renamed from: v2  reason: collision with root package name */
    public static final String f146773v2 = "Xmp";

    /* renamed from: v3  reason: collision with root package name */
    public static final short f146774v3 = 6;

    /* renamed from: v4  reason: collision with root package name */
    public static final short f146775v4 = 1;

    /* renamed from: v5  reason: collision with root package name */
    public static final int[] f146776v5 = {8};

    /* renamed from: v6  reason: collision with root package name */
    public static final int f146777v6 = 1;

    /* renamed from: v7  reason: collision with root package name */
    public static final byte f146778v7 = -61;

    /* renamed from: w0  reason: collision with root package name */
    public static final String f146779w0 = "ExposureTime";

    /* renamed from: w1  reason: collision with root package name */
    public static final String f146780w1 = "LensMake";

    /* renamed from: w2  reason: collision with root package name */
    public static final String f146781w2 = "NewSubfileType";

    /* renamed from: w3  reason: collision with root package name */
    public static final short f146782w3 = 255;

    /* renamed from: w4  reason: collision with root package name */
    public static final short f146783w4 = 0;

    /* renamed from: w5  reason: collision with root package name */
    public static final int f146784w5 = 0;

    /* renamed from: w6  reason: collision with root package name */
    public static final int f146785w6 = 2;

    /* renamed from: w7  reason: collision with root package name */
    public static final byte f146786w7 = -59;

    /* renamed from: x  reason: collision with root package name */
    public static final String f146787x = "ExifInterface";

    /* renamed from: x0  reason: collision with root package name */
    public static final String f146788x0 = "FNumber";

    /* renamed from: x1  reason: collision with root package name */
    public static final String f146789x1 = "LensModel";

    /* renamed from: x2  reason: collision with root package name */
    public static final String f146790x2 = "SubfileType";

    /* renamed from: x3  reason: collision with root package name */
    public static final short f146791x3 = 0;

    /* renamed from: x4  reason: collision with root package name */
    public static final short f146792x4 = 1;

    /* renamed from: x5  reason: collision with root package name */
    public static final int f146793x5 = 1;

    /* renamed from: x6  reason: collision with root package name */
    public static final int f146794x6 = 3;

    /* renamed from: x7  reason: collision with root package name */
    public static final byte f146795x7 = -58;

    /* renamed from: y  reason: collision with root package name */
    public static final boolean f146796y = Log.isLoggable(f146787x, 3);

    /* renamed from: y0  reason: collision with root package name */
    public static final String f146797y0 = "ExposureProgram";

    /* renamed from: y1  reason: collision with root package name */
    public static final String f146798y1 = "LensSerialNumber";

    /* renamed from: y2  reason: collision with root package name */
    public static final String f146799y2 = "ExifIFDPointer";

    /* renamed from: y3  reason: collision with root package name */
    public static final short f146800y3 = 1;

    /* renamed from: y4  reason: collision with root package name */
    public static final short f146801y4 = 2;

    /* renamed from: y5  reason: collision with root package name */
    public static final int f146802y5 = 2;

    /* renamed from: y6  reason: collision with root package name */
    public static final int f146803y6 = 4;

    /* renamed from: y7  reason: collision with root package name */
    public static final byte f146804y7 = -57;

    /* renamed from: z  reason: collision with root package name */
    public static final String f146805z = "ImageWidth";

    /* renamed from: z0  reason: collision with root package name */
    public static final String f146806z0 = "SpectralSensitivity";

    /* renamed from: z1  reason: collision with root package name */
    public static final String f146807z1 = "GPSVersionID";

    /* renamed from: z2  reason: collision with root package name */
    public static final String f146808z2 = "GPSInfoIFDPointer";

    /* renamed from: z3  reason: collision with root package name */
    public static final short f146809z3 = 2;

    /* renamed from: z4  reason: collision with root package name */
    public static final short f146810z4 = 3;

    /* renamed from: z5  reason: collision with root package name */
    public static final int f146811z5 = 6;

    /* renamed from: z6  reason: collision with root package name */
    public static final int f146812z6 = 5;

    /* renamed from: z7  reason: collision with root package name */
    public static final byte f146813z7 = -55;

    /* renamed from: a  reason: collision with root package name */
    public String f146814a;

    /* renamed from: b  reason: collision with root package name */
    public FileDescriptor f146815b;

    /* renamed from: c  reason: collision with root package name */
    public AssetManager.AssetInputStream f146816c;

    /* renamed from: d  reason: collision with root package name */
    public int f146817d;

    /* renamed from: e  reason: collision with root package name */
    public boolean f146818e;

    /* renamed from: f  reason: collision with root package name */
    public final HashMap<String, d>[] f146819f;

    /* renamed from: g  reason: collision with root package name */
    public Set<Integer> f146820g;

    /* renamed from: h  reason: collision with root package name */
    public ByteOrder f146821h;

    /* renamed from: i  reason: collision with root package name */
    public boolean f146822i;

    /* renamed from: j  reason: collision with root package name */
    public boolean f146823j;

    /* renamed from: k  reason: collision with root package name */
    public boolean f146824k;

    /* renamed from: l  reason: collision with root package name */
    public int f146825l;

    /* renamed from: m  reason: collision with root package name */
    public int f146826m;

    /* renamed from: n  reason: collision with root package name */
    public byte[] f146827n;

    /* renamed from: o  reason: collision with root package name */
    public int f146828o;

    /* renamed from: p  reason: collision with root package name */
    public int f146829p;

    /* renamed from: q  reason: collision with root package name */
    public int f146830q;

    /* renamed from: r  reason: collision with root package name */
    public int f146831r;

    /* renamed from: s  reason: collision with root package name */
    public int f146832s;

    /* renamed from: t  reason: collision with root package name */
    public int f146833t;

    /* renamed from: u  reason: collision with root package name */
    public boolean f146834u;

    /* renamed from: v  reason: collision with root package name */
    public boolean f146835v;

    /* renamed from: w  reason: collision with root package name */
    public boolean f146836w;

    /* renamed from: w1.a$a  reason: collision with other inner class name */
    /* compiled from: ExifInterface */
    public class C1238a extends MediaDataSource {

        /* renamed from: a  reason: collision with root package name */
        public long f146837a;

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ b f146838b;

        public C1238a(b bVar) {
            this.f146838b = bVar;
        }

        @Override // java.io.Closeable, java.lang.AutoCloseable
        public void close() throws IOException {
        }

        @Override // android.media.MediaDataSource
        public long getSize() throws IOException {
            return -1;
        }

        @Override // android.media.MediaDataSource
        public int readAt(long j10, byte[] bArr, int i10, int i11) throws IOException {
            if (i11 == 0) {
                return 0;
            }
            if (j10 < 0) {
                return -1;
            }
            try {
                long j11 = this.f146837a;
                if (j11 != j10) {
                    if (j11 >= 0 && j10 >= j11 + ((long) this.f146838b.available())) {
                        return -1;
                    }
                    this.f146838b.d(j10);
                    this.f146837a = j10;
                }
                if (i11 > this.f146838b.available()) {
                    i11 = this.f146838b.available();
                }
                int read = this.f146838b.read(bArr, i10, i11);
                if (read >= 0) {
                    this.f146837a += (long) read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.f146837a = -1;
            return -1;
        }
    }

    /* compiled from: ExifInterface */
    public static class b extends InputStream implements DataInput {

        /* renamed from: e  reason: collision with root package name */
        public static final ByteOrder f146840e = ByteOrder.LITTLE_ENDIAN;

        /* renamed from: f  reason: collision with root package name */
        public static final ByteOrder f146841f = ByteOrder.BIG_ENDIAN;

        /* renamed from: a  reason: collision with root package name */
        public DataInputStream f146842a;

        /* renamed from: b  reason: collision with root package name */
        public ByteOrder f146843b;

        /* renamed from: c  reason: collision with root package name */
        public final int f146844c;

        /* renamed from: d  reason: collision with root package name */
        public int f146845d;

        public b(InputStream inputStream) throws IOException {
            this(inputStream, ByteOrder.BIG_ENDIAN);
        }

        public int a() {
            return this.f146844c;
        }

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

        public int b() {
            return this.f146845d;
        }

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

        public void d(long j10) throws IOException {
            int i10 = this.f146845d;
            if (((long) i10) > j10) {
                this.f146845d = 0;
                this.f146842a.reset();
                this.f146842a.mark(this.f146844c);
            } else {
                j10 -= (long) i10;
            }
            int i11 = (int) j10;
            if (skipBytes(i11) != i11) {
                throw new IOException("Couldn't seek up to the byteCount");
            }
        }

        public void f(ByteOrder byteOrder) {
            this.f146843b = byteOrder;
        }

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

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

        @Override // java.io.DataInput
        public byte readByte() throws IOException {
            int i10 = this.f146845d + 1;
            this.f146845d = i10;
            if (i10 <= this.f146844c) {
                int read = this.f146842a.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public char readChar() throws IOException {
            this.f146845d += 2;
            return this.f146842a.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 i10, int i11) throws IOException {
            int i12 = this.f146845d + i11;
            this.f146845d = i12;
            if (i12 > this.f146844c) {
                throw new EOFException();
            } else if (this.f146842a.read(bArr, i10, i11) != i11) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override // java.io.DataInput
        public int readInt() throws IOException {
            int i10 = this.f146845d + 4;
            this.f146845d = i10;
            if (i10 <= this.f146844c) {
                int read = this.f146842a.read();
                int read2 = this.f146842a.read();
                int read3 = this.f146842a.read();
                int read4 = this.f146842a.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.f146843b;
                    if (byteOrder == f146840e) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f146841f) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    throw new IOException("Invalid byte order: " + this.f146843b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

        @Override // java.io.DataInput
        public long readLong() throws IOException {
            int i10 = this.f146845d + 8;
            this.f146845d = i10;
            if (i10 <= this.f146844c) {
                int read = this.f146842a.read();
                int read2 = this.f146842a.read();
                int read3 = this.f146842a.read();
                int read4 = this.f146842a.read();
                int read5 = this.f146842a.read();
                int read6 = this.f146842a.read();
                int read7 = this.f146842a.read();
                int read8 = this.f146842a.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.f146843b;
                    if (byteOrder == f146840e) {
                        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 == f146841f) {
                        return (((long) read) << 56) + (((long) read2) << 48) + (((long) read3) << 40) + (((long) read4) << 32) + (((long) read5) << 24) + (((long) read6) << 16) + (((long) read7) << 8) + ((long) read8);
                    }
                    throw new IOException("Invalid byte order: " + this.f146843b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public short readShort() throws IOException {
            int i10 = this.f146845d + 2;
            this.f146845d = i10;
            if (i10 <= this.f146844c) {
                int read = this.f146842a.read();
                int read2 = this.f146842a.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f146843b;
                    if (byteOrder == f146840e) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == f146841f) {
                        return (short) ((read << 8) + read2);
                    }
                    throw new IOException("Invalid byte order: " + this.f146843b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

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

        @Override // java.io.DataInput
        public int readUnsignedShort() throws IOException {
            int i10 = this.f146845d + 2;
            this.f146845d = i10;
            if (i10 <= this.f146844c) {
                int read = this.f146842a.read();
                int read2 = this.f146842a.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f146843b;
                    if (byteOrder == f146840e) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == f146841f) {
                        return (read << 8) + read2;
                    }
                    throw new IOException("Invalid byte order: " + this.f146843b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override // java.io.DataInput
        public int skipBytes(int i10) throws IOException {
            int min = Math.min(i10, this.f146844c - this.f146845d);
            int i11 = 0;
            while (i11 < min) {
                i11 += this.f146842a.skipBytes(min - i11);
            }
            this.f146845d += i11;
            return i11;
        }

        public b(InputStream inputStream, ByteOrder byteOrder) throws IOException {
            this.f146843b = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f146842a = dataInputStream;
            int available = dataInputStream.available();
            this.f146844c = available;
            this.f146845d = 0;
            this.f146842a.mark(available);
            this.f146843b = byteOrder;
        }

        @Override // java.io.InputStream
        public int read(byte[] bArr, int i10, int i11) throws IOException {
            int read = this.f146842a.read(bArr, i10, i11);
            this.f146845d += read;
            return read;
        }

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

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

    /* compiled from: ExifInterface */
    public static class c extends FilterOutputStream {

        /* renamed from: a  reason: collision with root package name */
        public final OutputStream f146846a;

        /* renamed from: b  reason: collision with root package name */
        public ByteOrder f146847b;

        public c(OutputStream outputStream, ByteOrder byteOrder) {
            super(outputStream);
            this.f146846a = outputStream;
            this.f146847b = byteOrder;
        }

        public void a(ByteOrder byteOrder) {
            this.f146847b = byteOrder;
        }

        public void b(int i10) throws IOException {
            this.f146846a.write(i10);
        }

        public void c(int i10) throws IOException {
            ByteOrder byteOrder = this.f146847b;
            if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
                this.f146846a.write((i10 >>> 0) & 255);
                this.f146846a.write((i10 >>> 8) & 255);
                this.f146846a.write((i10 >>> 16) & 255);
                this.f146846a.write((i10 >>> 24) & 255);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                this.f146846a.write((i10 >>> 24) & 255);
                this.f146846a.write((i10 >>> 16) & 255);
                this.f146846a.write((i10 >>> 8) & 255);
                this.f146846a.write((i10 >>> 0) & 255);
            }
        }

        public void d(short s10) throws IOException {
            ByteOrder byteOrder = this.f146847b;
            if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
                this.f146846a.write((s10 >>> 0) & 255);
                this.f146846a.write((s10 >>> 8) & 255);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                this.f146846a.write((s10 >>> 8) & 255);
                this.f146846a.write((s10 >>> 0) & 255);
            }
        }

        public void f(long j10) throws IOException {
            c((int) j10);
        }

        public void g(int i10) throws IOException {
            d((short) i10);
        }

        @Override // java.io.OutputStream, java.io.FilterOutputStream
        public void write(byte[] bArr) throws IOException {
            this.f146846a.write(bArr);
        }

        @Override // java.io.OutputStream, java.io.FilterOutputStream
        public void write(byte[] bArr, int i10, int i11) throws IOException {
            this.f146846a.write(bArr, i10, i11);
        }
    }

    /* compiled from: ExifInterface */
    public static class d {

        /* renamed from: e  reason: collision with root package name */
        public static final long f146848e = -1;

        /* renamed from: a  reason: collision with root package name */
        public final int f146849a;

        /* renamed from: b  reason: collision with root package name */
        public final int f146850b;

        /* renamed from: c  reason: collision with root package name */
        public final long f146851c;

        /* renamed from: d  reason: collision with root package name */
        public final byte[] f146852d;

        public d(int i10, int i11, byte[] bArr) {
            this(i10, i11, -1, bArr);
        }

        public static d a(String str) {
            if (str.length() != 1 || str.charAt(0) < '0' || str.charAt(0) > '1') {
                byte[] bytes = str.getBytes(a.f146714n7);
                return new d(1, bytes.length, bytes);
            }
            return new d(1, 1, new byte[]{(byte) (str.charAt(0) - '0')});
        }

        public static d b(double d10, ByteOrder byteOrder) {
            return c(new double[]{d10}, byteOrder);
        }

        public static d c(double[] dArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[12] * dArr.length)]);
            wrap.order(byteOrder);
            for (double d10 : dArr) {
                wrap.putDouble(d10);
            }
            return new d(12, dArr.length, wrap.array());
        }

        public static d d(int i10, ByteOrder byteOrder) {
            return e(new int[]{i10}, byteOrder);
        }

        public static d e(int[] iArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[9] * iArr.length)]);
            wrap.order(byteOrder);
            for (int i10 : iArr) {
                wrap.putInt(i10);
            }
            return new d(9, iArr.length, wrap.array());
        }

        public static d f(h hVar, ByteOrder byteOrder) {
            return g(new h[]{hVar}, byteOrder);
        }

        public static d g(h[] hVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[10] * hVarArr.length)]);
            wrap.order(byteOrder);
            for (h hVar : hVarArr) {
                wrap.putInt((int) hVar.f146857a);
                wrap.putInt((int) hVar.f146858b);
            }
            return new d(10, hVarArr.length, wrap.array());
        }

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

        public static d i(long j10, ByteOrder byteOrder) {
            return j(new long[]{j10}, byteOrder);
        }

        public static d j(long[] jArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[4] * jArr.length)]);
            wrap.order(byteOrder);
            for (long j10 : jArr) {
                wrap.putInt((int) j10);
            }
            return new d(4, jArr.length, wrap.array());
        }

        public static d k(h hVar, ByteOrder byteOrder) {
            return l(new h[]{hVar}, byteOrder);
        }

        public static d l(h[] hVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[5] * hVarArr.length)]);
            wrap.order(byteOrder);
            for (h hVar : hVarArr) {
                wrap.putInt((int) hVar.f146857a);
                wrap.putInt((int) hVar.f146858b);
            }
            return new d(5, hVarArr.length, wrap.array());
        }

        public static d m(int i10, ByteOrder byteOrder) {
            return n(new int[]{i10}, byteOrder);
        }

        public static d n(int[] iArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[(a.J6[3] * iArr.length)]);
            wrap.order(byteOrder);
            for (int i10 : iArr) {
                wrap.putShort((short) i10);
            }
            return new d(3, iArr.length, wrap.array());
        }

        public double o(ByteOrder byteOrder) {
            Object r10 = r(byteOrder);
            if (r10 == null) {
                throw new NumberFormatException("NULL can't be converted to a double value");
            } else if (r10 instanceof String) {
                return Double.parseDouble((String) r10);
            } else {
                if (r10 instanceof long[]) {
                    long[] jArr = (long[]) r10;
                    if (jArr.length == 1) {
                        return (double) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r10 instanceof int[]) {
                    int[] iArr = (int[]) r10;
                    if (iArr.length == 1) {
                        return (double) iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r10 instanceof double[]) {
                    double[] dArr = (double[]) r10;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r10 instanceof h[]) {
                    h[] hVarArr = (h[]) r10;
                    if (hVarArr.length == 1) {
                        return hVarArr[0].a();
                    }
                    throw new NumberFormatException("There are more than one component");
                } else {
                    throw new NumberFormatException("Couldn't find a double value");
                }
            }
        }

        public int p(ByteOrder byteOrder) {
            Object r10 = r(byteOrder);
            if (r10 == null) {
                throw new NumberFormatException("NULL can't be converted to a integer value");
            } else if (r10 instanceof String) {
                return Integer.parseInt((String) r10);
            } else {
                if (r10 instanceof long[]) {
                    long[] jArr = (long[]) r10;
                    if (jArr.length == 1) {
                        return (int) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (r10 instanceof int[]) {
                    int[] iArr = (int[]) r10;
                    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");
                }
            }
        }

        public String q(ByteOrder byteOrder) {
            Object r10 = r(byteOrder);
            if (r10 == null) {
                return null;
            }
            if (r10 instanceof String) {
                return (String) r10;
            }
            StringBuilder sb2 = new StringBuilder();
            int i10 = 0;
            if (r10 instanceof long[]) {
                long[] jArr = (long[]) r10;
                while (i10 < jArr.length) {
                    sb2.append(jArr[i10]);
                    i10++;
                    if (i10 != jArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (r10 instanceof int[]) {
                int[] iArr = (int[]) r10;
                while (i10 < iArr.length) {
                    sb2.append(iArr[i10]);
                    i10++;
                    if (i10 != iArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (r10 instanceof double[]) {
                double[] dArr = (double[]) r10;
                while (i10 < dArr.length) {
                    sb2.append(dArr[i10]);
                    i10++;
                    if (i10 != dArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (!(r10 instanceof h[])) {
                return null;
            } else {
                h[] hVarArr = (h[]) r10;
                while (i10 < hVarArr.length) {
                    sb2.append(hVarArr[i10].f146857a);
                    sb2.append('/');
                    sb2.append(hVarArr[i10].f146858b);
                    i10++;
                    if (i10 != hVarArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
        }

        /* JADX WARNING: Removed duplicated region for block: B:138:0x0192 A[SYNTHETIC, Splitter:B:138:0x0192] */
        /* JADX WARNING: Removed duplicated region for block: B:146:0x019f A[SYNTHETIC, Splitter:B:146:0x019f] */
        public Object r(ByteOrder byteOrder) {
            Throwable th2;
            IOException e10;
            b bVar;
            byte b10;
            byte[] bArr;
            b bVar2 = null;
            try {
                bVar = new b(this.f146852d);
                try {
                    bVar.f(byteOrder);
                    boolean z10 = true;
                    int i10 = 0;
                    switch (this.f146849a) {
                        case 1:
                        case 6:
                            byte[] bArr2 = this.f146852d;
                            if (bArr2.length != 1 || bArr2[0] < 0 || bArr2[0] > 1) {
                                String str = new String(bArr2, a.f146714n7);
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e(a.f146787x, "IOException occurred while closing InputStream", e11);
                                }
                                return str;
                            }
                            String str2 = new String(new char[]{(char) (bArr2[0] + 48)});
                            try {
                                bVar.close();
                            } catch (IOException e12) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e12);
                            }
                            return str2;
                        case 2:
                        case 7:
                            if (this.f146850b >= a.K6.length) {
                                int i11 = 0;
                                while (true) {
                                    bArr = a.K6;
                                    if (i11 < bArr.length) {
                                        if (this.f146852d[i11] != bArr[i11]) {
                                            z10 = false;
                                        } else {
                                            i11++;
                                        }
                                    }
                                }
                                if (z10) {
                                    i10 = bArr.length;
                                }
                            }
                            StringBuilder sb2 = new StringBuilder();
                            while (i10 < this.f146850b && (b10 = this.f146852d[i10]) != 0) {
                                if (b10 >= 32) {
                                    sb2.append((char) b10);
                                } else {
                                    sb2.append(rz.d.f114399a);
                                }
                                i10++;
                            }
                            String sb3 = sb2.toString();
                            try {
                                bVar.close();
                            } catch (IOException e13) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e13);
                            }
                            return sb3;
                        case 3:
                            int[] iArr = new int[this.f146850b];
                            while (i10 < this.f146850b) {
                                iArr[i10] = bVar.readUnsignedShort();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e14) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e14);
                            }
                            return iArr;
                        case 4:
                            long[] jArr = new long[this.f146850b];
                            while (i10 < this.f146850b) {
                                jArr[i10] = bVar.c();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e15) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e15);
                            }
                            return jArr;
                        case 5:
                            h[] hVarArr = new h[this.f146850b];
                            while (i10 < this.f146850b) {
                                hVarArr[i10] = new h(bVar.c(), bVar.c());
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e16) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e16);
                            }
                            return hVarArr;
                        case 8:
                            int[] iArr2 = new int[this.f146850b];
                            while (i10 < this.f146850b) {
                                iArr2[i10] = bVar.readShort();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e17) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e17);
                            }
                            return iArr2;
                        case 9:
                            int[] iArr3 = new int[this.f146850b];
                            while (i10 < this.f146850b) {
                                iArr3[i10] = bVar.readInt();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e18) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e18);
                            }
                            return iArr3;
                        case 10:
                            h[] hVarArr2 = new h[this.f146850b];
                            while (i10 < this.f146850b) {
                                hVarArr2[i10] = new h((long) bVar.readInt(), (long) bVar.readInt());
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e19) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e19);
                            }
                            return hVarArr2;
                        case 11:
                            double[] dArr = new double[this.f146850b];
                            while (i10 < this.f146850b) {
                                dArr[i10] = (double) bVar.readFloat();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e20) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e20);
                            }
                            return dArr;
                        case 12:
                            double[] dArr2 = new double[this.f146850b];
                            while (i10 < this.f146850b) {
                                dArr2[i10] = bVar.readDouble();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e21) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e21);
                            }
                            return dArr2;
                        default:
                            try {
                                bVar.close();
                            } catch (IOException e22) {
                                Log.e(a.f146787x, "IOException occurred while closing InputStream", e22);
                            }
                            return null;
                    }
                } catch (IOException e23) {
                    e10 = e23;
                    try {
                        Log.w(a.f146787x, "IOException occurred during reading a value", e10);
                        if (bVar != null) {
                        }
                        return null;
                    } catch (Throwable th3) {
                        th2 = th3;
                        bVar2 = bVar;
                        if (bVar2 != null) {
                        }
                        throw th2;
                    }
                }
            } catch (IOException e24) {
                e10 = e24;
                bVar = null;
                Log.w(a.f146787x, "IOException occurred during reading a value", e10);
                if (bVar != null) {
                    try {
                        bVar.close();
                    } catch (IOException e25) {
                        Log.e(a.f146787x, "IOException occurred while closing InputStream", e25);
                    }
                }
                return null;
            } catch (Throwable th4) {
                th2 = th4;
                if (bVar2 != null) {
                    try {
                        bVar2.close();
                    } catch (IOException e26) {
                        Log.e(a.f146787x, "IOException occurred while closing InputStream", e26);
                    }
                }
                throw th2;
            }
        }

        public int s() {
            return a.J6[this.f146849a] * this.f146850b;
        }

        public String toString() {
            return "(" + a.I6[this.f146849a] + ", data length:" + this.f146852d.length + ")";
        }

        public d(int i10, int i11, long j10, byte[] bArr) {
            this.f146849a = i10;
            this.f146850b = i11;
            this.f146851c = j10;
            this.f146852d = bArr;
        }
    }

    @x0({x0.a.LIBRARY})
    @Retention(RetentionPolicy.SOURCE)
    /* compiled from: ExifInterface */
    public @interface e {
    }

    @x0({x0.a.LIBRARY})
    @Retention(RetentionPolicy.SOURCE)
    /* compiled from: ExifInterface */
    public @interface g {
    }

    /* compiled from: ExifInterface */
    public static class h {

        /* renamed from: a  reason: collision with root package name */
        public final long f146857a;

        /* renamed from: b  reason: collision with root package name */
        public final long f146858b;

        public h(double d10) {
            this((long) (d10 * 10000.0d), 10000);
        }

        public double a() {
            return ((double) this.f146857a) / ((double) this.f146858b);
        }

        public String toString() {
            return this.f146857a + "/" + this.f146858b;
        }

        public h(long j10, long j11) {
            if (j11 == 0) {
                this.f146857a = 0;
                this.f146858b = 1;
                return;
            }
            this.f146857a = j10;
            this.f146858b = j11;
        }
    }

    static {
        f[] fVarArr = {new f(f146781w2, i5.d.f70975l, 4), new f(f146790x2, 255, 4), new f(f146805z, 256, 3, 4), new f(A, 257, 3, 4), new f(B, 258, 3), new f(C, 259, 3), new f(D, 262, 3), new f(X, SubsamplingScaleImageView.ORIENTATION_270, 2), new f(Y, 271, 2), new f("Model", 272, 2), new f(M, AudioAttributesCompat.O, 3, 4), new f(E, 274, 3), new f(F, 277, 3), new f(N, 278, 3, 4), new f(O, 279, 3, 4), new f(J, 282, 5), new f(K, 283, 5), new f(G, 284, 3), new f(L, cn.c.f22271m, 3), new f(R, 301, 3), new f(f146603a0, 305, 2), new f(W, 306, 2), new f(f146611b0, androidx.core.widget.a.A, 2), new f(S, 318, 5), new f(T, 319, 5), new f(B2, 330, 4), new f(P, k.f58634j, 4), new f(Q, 514, 4), new f(U, 529, 5), new f(H, 530, 3), new f(I, 531, 3), new f(V, 532, 5), new f(f146619c0, 33432, 2), new f(f146799y2, 34665, 4), new f(f146808z2, 34853, 4), new f(f146749s2, 4, 4), new f(f146733q2, 5, 4), new f(f146725p2, 6, 4), new f(f146741r2, 7, 4), new f(f146757t2, 23, 3), new f(f146765u2, 46, 7), new f(f146773v2, 700, 1)};
        L6 = fVarArr;
        f[] fVarArr2 = {new f(f146779w0, 33434, 5), new f(f146788x0, 33437, 5), new f(f146797y0, 34850, 3), new f(f146806z0, 34852, 2), new f(B0, 34855, 3), new f(C0, 34856, 7), new f(D0, 34864, 3), new f(E0, 34865, 4), new f(F0, 34866, 4), new f(G0, 34867, 4), new f(H0, 34868, 4), new f(I0, 34869, 4), new f(f146627d0, 36864, 2), new f(f146715o0, 36867, 2), new f(f146723p0, 36868, 2), new f(f146731q0, 36880, 2), new f(f146739r0, 36881, 2), new f(f146747s0, 36882, 2), new f(f146675j0, 37121, 7), new f(f146683k0, 37122, 5), new f(J0, 37377, 10), new f(K0, 37378, 5), new f(L0, 37379, 10), new f(M0, 37380, 10), new f(N0, 37381, 5), new f(O0, 37382, 5), new f(P0, 37383, 3), new f(Q0, 37384, 3), new f(R0, 37385, 3), new f(T0, 37386, 5), new f(S0, 37396, 3), new f(f146691l0, 37500, 7), new f(f146699m0, 37510, 7), new f(f146755t0, 37520, 2), new f(f146763u0, 37521, 2), new f(f146771v0, 37522, 2), new f(f146635e0, 40960, 7), new f(f146643f0, 40961, 3), new f(f146659h0, 40962, 3, 4), new f(f146667i0, 40963, 3, 4), new f(f146707n0, 40964, 2), new f(A2, 40965, 4), new f(U0, 41483, 5), new f(V0, 41484, 7), new f(W0, 41486, 5), new f(X0, 41487, 5), new f(Y0, 41488, 3), new f(Z0, 41492, 3), new f(f146604a1, 41493, 5), new f(f146612b1, 41495, 3), new f(f146620c1, 41728, 7), new f(f146628d1, 41729, 7), new f(f146636e1, 41730, 7), new f(f146644f1, 41985, 3), new f(f146652g1, 41986, 3), new f(f146660h1, 41987, 3), new f(f146668i1, 41988, 5), new f(f146676j1, 41989, 3), new f(f146684k1, 41990, 3), new f(f146692l1, 41991, 3), new f(f146700m1, 41992, 3), new f(f146708n1, 41993, 3), new f(f146716o1, 41994, 3), new f(f146724p1, 41995, 7), new f(f146732q1, 41996, 3), new f(f146740r1, 42016, 2), new f("CameraOwnerName", 42032, 2), new f(f146764u1, 42033, 2), new f(f146772v1, 42034, 5), new f(f146780w1, 42035, 2), new f(f146789x1, 42036, 2), new f(f146651g0, 42240, 5), new f(f146677j2, 50706, 1), new f(f146685k2, 50720, 3, 4)};
        M6 = fVarArr2;
        f[] fVarArr3 = {new f(f146807z1, 0, 1), new f(A1, 1, 2), new f(B1, 2, 5), new f(C1, 3, 2), new f(D1, 4, 5), new f(E1, 5, 1), new f(F1, 6, 5), new f(G1, 7, 5), new f(H1, 8, 2), new f(I1, 9, 2), new f(J1, 10, 2), new f(K1, 11, 5), new f(L1, 12, 2), new f(M1, 13, 5), new f(N1, 14, 2), new f(O1, 15, 5), new f(P1, 16, 2), new f(Q1, 17, 5), new f(R1, 18, 2), new f(S1, 19, 2), new f(T1, 20, 5), new f(U1, 21, 2), new f(V1, 22, 5), new f(W1, 23, 2), new f(X1, 24, 5), new f(Y1, 25, 2), new f(Z1, 26, 5), new f(f146605a2, 27, 7), new f(f146613b2, 28, 7), new f(f146621c2, 29, 2), new f(f146629d2, 30, 3), new f(f146637e2, 31, 5)};
        N6 = fVarArr3;
        f[] fVarArr4 = {new f(f146645f2, 1, 2)};
        O6 = fVarArr4;
        f[] fVarArr5 = {new f(f146781w2, i5.d.f70975l, 4), new f(f146790x2, 255, 4), new f(f146661h2, 256, 3, 4), new f(f146653g2, 257, 3, 4), new f(B, 258, 3), new f(C, 259, 3), new f(D, 262, 3), new f(X, SubsamplingScaleImageView.ORIENTATION_270, 2), new f(Y, 271, 2), new f("Model", 272, 2), new f(M, AudioAttributesCompat.O, 3, 4), new f(f146669i2, 274, 3), new f(F, 277, 3), new f(N, 278, 3, 4), new f(O, 279, 3, 4), new f(J, 282, 5), new f(K, 283, 5), new f(G, 284, 3), new f(L, cn.c.f22271m, 3), new f(R, 301, 3), new f(f146603a0, 305, 2), new f(W, 306, 2), new f(f146611b0, androidx.core.widget.a.A, 2), new f(S, 318, 5), new f(T, 319, 5), new f(B2, 330, 4), new f(P, k.f58634j, 4), new f(Q, 514, 4), new f(U, 529, 5), new f(H, 530, 3), new f(I, 531, 3), new f(V, 532, 5), new f(f146619c0, 33432, 2), new f(f146799y2, 34665, 4), new f(f146808z2, 34853, 4), new f(f146677j2, 50706, 1), new f(f146685k2, 50720, 3, 4)};
        P6 = fVarArr5;
        f[] fVarArr6 = {new f(f146693l2, 256, 7), new f(C2, 8224, 4), new f(D2, 8256, 4)};
        R6 = fVarArr6;
        f[] fVarArr7 = {new f(f146701m2, 257, 4), new f(f146709n2, 258, 4)};
        S6 = fVarArr7;
        f[] fVarArr8 = {new f(f146717o2, 4371, 3)};
        T6 = fVarArr8;
        f[] fVarArr9 = {new f(f146643f0, 55, 3)};
        U6 = fVarArr9;
        f[][] fVarArr10 = {fVarArr, fVarArr2, fVarArr3, fVarArr4, fVarArr5, fVarArr, fVarArr6, fVarArr7, fVarArr8, fVarArr9};
        f146650f7 = fVarArr10;
        f146682j7 = new HashMap[fVarArr10.length];
        f146690k7 = new HashMap[fVarArr10.length];
        Charset forName = Charset.forName("US-ASCII");
        f146714n7 = forName;
        f146722o7 = "Exif\u0000\u0000".getBytes(forName);
        f146730p7 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        f146737q6 = simpleDateFormat;
        simpleDateFormat.setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            f[][] fVarArr11 = f146650f7;
            if (i10 < fVarArr11.length) {
                f146682j7[i10] = new HashMap<>();
                f146690k7[i10] = new HashMap<>();
                f[] fVarArr12 = fVarArr11[i10];
                for (f fVar : fVarArr12) {
                    f146682j7[i10].put(Integer.valueOf(fVar.f146853a), fVar);
                    f146690k7[i10].put(fVar.f146854b, fVar);
                }
                i10++;
            } else {
                HashMap<Integer, Integer> hashMap = f146706m7;
                f[] fVarArr13 = f146658g7;
                hashMap.put(Integer.valueOf(fVarArr13[0].f146853a), 5);
                hashMap.put(Integer.valueOf(fVarArr13[1].f146853a), 1);
                hashMap.put(Integer.valueOf(fVarArr13[2].f146853a), 2);
                hashMap.put(Integer.valueOf(fVarArr13[3].f146853a), 3);
                hashMap.put(Integer.valueOf(fVarArr13[4].f146853a), 7);
                hashMap.put(Integer.valueOf(fVarArr13[5].f146853a), 8);
                return;
            }
        }
    }

    public a(@m0 File file) throws IOException {
        f[][] fVarArr = f146650f7;
        this.f146819f = new HashMap[fVarArr.length];
        this.f146820g = new HashSet(fVarArr.length);
        this.f146821h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(file, "file cannot be null");
        U(file.getAbsolutePath());
    }

    public static boolean F0(byte[] bArr, byte[] bArr2) {
        if (bArr == null || bArr2 == null || bArr.length < bArr2.length) {
            return false;
        }
        for (int i10 = 0; i10 < bArr2.length; i10++) {
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
        }
        return true;
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(3:68|69|70) */
    /* JADX WARNING: Code restructure failed: missing block: B:69:?, code lost:
        java.lang.Double.parseDouble(r12);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:70:0x015c, code lost:
        return new android.util.Pair<>(12, -1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:73:0x0162, code lost:
        return new android.util.Pair<>(2, -1);
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:68:0x014e */
    public static Pair<Integer, Integer> P(String str) {
        if (str.contains(",")) {
            String[] split = str.split(",", -1);
            Pair<Integer, Integer> P8 = P(split[0]);
            if (((Integer) P8.first).intValue() == 2) {
                return P8;
            }
            for (int i10 = 1; i10 < split.length; i10++) {
                Pair<Integer, Integer> P9 = P(split[i10]);
                int intValue = (((Integer) P9.first).equals(P8.first) || ((Integer) P9.second).equals(P8.first)) ? ((Integer) P8.first).intValue() : -1;
                int intValue2 = (((Integer) P8.second).intValue() == -1 || (!((Integer) P9.first).equals(P8.second) && !((Integer) P9.second).equals(P8.second))) ? -1 : ((Integer) P8.second).intValue();
                if (intValue == -1 && intValue2 == -1) {
                    return new Pair<>(2, -1);
                }
                if (intValue == -1) {
                    P8 = new Pair<>(Integer.valueOf(intValue2), -1);
                } else if (intValue2 == -1) {
                    P8 = new Pair<>(Integer.valueOf(intValue), -1);
                }
            }
            return P8;
        } else if (str.contains("/")) {
            String[] split2 = str.split("/", -1);
            if (split2.length == 2) {
                try {
                    long parseDouble = (long) Double.parseDouble(split2[0]);
                    long parseDouble2 = (long) Double.parseDouble(split2[1]);
                    if (parseDouble >= 0) {
                        if (parseDouble2 >= 0) {
                            if (parseDouble <= 2147483647L) {
                                if (parseDouble2 <= 2147483647L) {
                                    return new Pair<>(10, 5);
                                }
                            }
                            return new Pair<>(5, -1);
                        }
                    }
                    return new Pair<>(10, -1);
                } catch (NumberFormatException unused) {
                }
            }
            return new Pair<>(2, -1);
        } else {
            Long valueOf = Long.valueOf(Long.parseLong(str));
            if (valueOf.longValue() >= 0 && valueOf.longValue() <= 65535) {
                return new Pair<>(3, 4);
            }
            if (valueOf.longValue() < 0) {
                return new Pair<>(9, -1);
            }
            return new Pair<>(4, -1);
        }
    }

    public static boolean V(BufferedInputStream bufferedInputStream) throws IOException {
        byte[] bArr = f146722o7;
        bufferedInputStream.mark(bArr.length);
        byte[] bArr2 = new byte[bArr.length];
        bufferedInputStream.read(bArr2);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr3 = f146722o7;
            if (i10 >= bArr3.length) {
                return true;
            }
            if (bArr2[i10] != bArr3[i10]) {
                return false;
            }
            i10++;
        }
    }

    public static boolean Y(byte[] bArr) throws IOException {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = F5;
            if (i10 >= bArr2.length) {
                return true;
            }
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
            i10++;
        }
    }

    public static String b(byte[] bArr) {
        StringBuilder sb2 = new StringBuilder(bArr.length * 2);
        for (int i10 = 0; i10 < bArr.length; i10++) {
            sb2.append(String.format("%02x", Byte.valueOf(bArr[i10])));
        }
        return sb2.toString();
    }

    public static void c(FileDescriptor fileDescriptor) {
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                Os.close(fileDescriptor);
            } catch (Exception unused) {
                Log.e(f146787x, "Error closing fd.");
            }
        } else {
            Log.e(f146787x, "closeFileDescriptor is called in API < 21, which must be wrong.");
        }
    }

    public static void d(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (RuntimeException e10) {
                throw e10;
            } catch (Exception unused) {
            }
        }
    }

    public static boolean d0(FileDescriptor fileDescriptor) {
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                Os.lseek(fileDescriptor, 0, OsConstants.SEEK_CUR);
                return true;
            } catch (Exception unused) {
                if (f146796y) {
                    Log.d(f146787x, "The file descriptor for the given input is not seekable");
                }
            }
        }
        return false;
    }

    public static double f(String str, String str2) {
        try {
            String[] split = str.split(",", -1);
            String[] split2 = split[0].split("/", -1);
            String[] split3 = split[1].split("/", -1);
            String[] split4 = split[2].split("/", -1);
            double parseDouble = (Double.parseDouble(split2[0].trim()) / Double.parseDouble(split2[1].trim())) + ((Double.parseDouble(split3[0].trim()) / Double.parseDouble(split3[1].trim())) / 60.0d) + ((Double.parseDouble(split4[0].trim()) / Double.parseDouble(split4[1].trim())) / 3600.0d);
            if (!str2.equals(T4)) {
                if (!str2.equals(V4)) {
                    if (!str2.equals("N")) {
                        if (!str2.equals(U4)) {
                            throw new IllegalArgumentException();
                        }
                    }
                    return parseDouble;
                }
            }
            return -parseDouble;
        } catch (ArrayIndexOutOfBoundsException | NumberFormatException unused) {
            throw new IllegalArgumentException();
        }
    }

    public static long[] g(Object obj) {
        if (obj instanceof int[]) {
            int[] iArr = (int[]) obj;
            long[] jArr = new long[iArr.length];
            for (int i10 = 0; i10 < iArr.length; i10++) {
                jArr[i10] = (long) iArr[i10];
            }
            return jArr;
        } else if (obj instanceof long[]) {
            return (long[]) obj;
        } else {
            return null;
        }
    }

    public static boolean g0(@m0 String str) {
        Objects.requireNonNull(str, "mimeType shouldn't be null");
        String lowerCase = str.toLowerCase(Locale.ROOT);
        lowerCase.hashCode();
        char c10 = 65535;
        switch (lowerCase.hashCode()) {
            case -1875291391:
                if (lowerCase.equals("image/x-fuji-raf")) {
                    c10 = 0;
                    break;
                }
                break;
            case -1635437028:
                if (lowerCase.equals("image/x-samsung-srw")) {
                    c10 = 1;
                    break;
                }
                break;
            case -1594371159:
                if (lowerCase.equals("image/x-sony-arw")) {
                    c10 = 2;
                    break;
                }
                break;
            case -1487464693:
                if (lowerCase.equals("image/heic")) {
                    c10 = 3;
                    break;
                }
                break;
            case -1487464690:
                if (lowerCase.equals("image/heif")) {
                    c10 = 4;
                    break;
                }
                break;
            case -1487394660:
                if (lowerCase.equals("image/jpeg")) {
                    c10 = 5;
                    break;
                }
                break;
            case -1487018032:
                if (lowerCase.equals(PictureMimeType.MIME_TYPE_WEBP)) {
                    c10 = 6;
                    break;
                }
                break;
            case -1423313290:
                if (lowerCase.equals("image/x-adobe-dng")) {
                    c10 = 7;
                    break;
                }
                break;
            case -985160897:
                if (lowerCase.equals("image/x-panasonic-rw2")) {
                    c10 = '\b';
                    break;
                }
                break;
            case -879258763:
                if (lowerCase.equals("image/png")) {
                    c10 = '\t';
                    break;
                }
                break;
            case -332763809:
                if (lowerCase.equals("image/x-pentax-pef")) {
                    c10 = '\n';
                    break;
                }
                break;
            case 1378106698:
                if (lowerCase.equals("image/x-olympus-orf")) {
                    c10 = 11;
                    break;
                }
                break;
            case 2099152104:
                if (lowerCase.equals("image/x-nikon-nef")) {
                    c10 = '\f';
                    break;
                }
                break;
            case 2099152524:
                if (lowerCase.equals("image/x-nikon-nrw")) {
                    c10 = '\r';
                    break;
                }
                break;
            case 2111234748:
                if (lowerCase.equals("image/x-canon-cr2")) {
                    c10 = 14;
                    break;
                }
                break;
        }
        switch (c10) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case '\b':
            case '\t':
            case '\n':
            case 11:
            case '\f':
            case '\r':
            case 14:
                return true;
            default:
                return false;
        }
    }

    public static int h(InputStream inputStream, OutputStream outputStream) throws IOException {
        byte[] bArr = new byte[8192];
        int i10 = 0;
        while (true) {
            int read = inputStream.read(bArr);
            if (read == -1) {
                return i10;
            }
            i10 += read;
            outputStream.write(bArr, 0, read);
        }
    }

    public static void i(InputStream inputStream, OutputStream outputStream, int i10) throws IOException {
        byte[] bArr = new byte[8192];
        while (i10 > 0) {
            int min = Math.min(i10, 8192);
            int read = inputStream.read(bArr, 0, min);
            if (read == min) {
                i10 -= read;
                outputStream.write(bArr, 0, read);
            } else {
                throw new IOException("Failed to copy the given amount of bytes from the inputstream to the output stream.");
            }
        }
    }

    public static long l0(@o0 String str, @o0 String str2) {
        if (str != null && Y7.matcher(str).matches()) {
            try {
                Date parse = f146737q6.parse(str, new ParsePosition(0));
                if (parse == null) {
                    return -1;
                }
                long time = parse.getTime();
                if (str2 == null) {
                    return time;
                }
                try {
                    long parseLong = Long.parseLong(str2);
                    while (parseLong > 1000) {
                        parseLong /= 10;
                    }
                    return time + parseLong;
                } catch (NumberFormatException unused) {
                    return time;
                }
            } catch (IllegalArgumentException unused2) {
            }
        }
        return -1;
    }

    @Deprecated
    public boolean A(float[] fArr) {
        double[] B8 = B();
        if (B8 == null) {
            return false;
        }
        fArr[0] = (float) B8[0];
        fArr[1] = (float) B8[1];
        return true;
    }

    public void A0(@m0 String str, @o0 String str2) {
        int i10;
        f fVar;
        int i11;
        String str3;
        String str4;
        String str5 = str;
        String str6 = str2;
        Objects.requireNonNull(str5, "tag shouldn't be null");
        boolean equals = A0.equals(str5);
        String str7 = f146787x;
        if (equals) {
            if (f146796y) {
                Log.d(str7, "setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str5 = B0;
        }
        int i12 = 2;
        int i13 = 1;
        if (str6 != null && f146698l7.contains(str5)) {
            if (str5.equals(G1)) {
                Matcher matcher = Z7.matcher(str6);
                if (!matcher.find()) {
                    Log.w(str7, "Invalid value for " + str5 + " : " + str6);
                    return;
                }
                str6 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1";
            } else {
                try {
                    str6 = new h(Double.parseDouble(str2)).toString();
                } catch (NumberFormatException unused) {
                    Log.w(str7, "Invalid value for " + str5 + " : " + str6);
                    return;
                }
            }
        }
        int i14 = 0;
        int i15 = 0;
        while (i15 < f146650f7.length) {
            if ((i15 != 4 || this.f146822i) && (fVar = f146690k7[i15].get(str5)) != null) {
                if (str6 == null) {
                    this.f146819f[i15].remove(str5);
                } else {
                    Pair<Integer, Integer> P8 = P(str6);
                    int i16 = -1;
                    if (fVar.f146855c == ((Integer) P8.first).intValue() || fVar.f146855c == ((Integer) P8.second).intValue()) {
                        i11 = fVar.f146855c;
                    } else {
                        int i17 = fVar.f146856d;
                        if (i17 == -1 || !(i17 == ((Integer) P8.first).intValue() || fVar.f146856d == ((Integer) P8.second).intValue())) {
                            int i18 = fVar.f146855c;
                            if (i18 == i13 || i18 == 7 || i18 == i12) {
                                i11 = i18;
                            } else if (f146796y) {
                                StringBuilder sb2 = new StringBuilder();
                                sb2.append("Given tag (");
                                sb2.append(str5);
                                sb2.append(") value didn't match with one of expected formats: ");
                                String[] strArr = I6;
                                sb2.append(strArr[fVar.f146855c]);
                                String str8 = "";
                                sb2.append(fVar.f146856d == -1 ? str8 : ", " + strArr[fVar.f146856d]);
                                sb2.append(" (guess: ");
                                sb2.append(strArr[((Integer) P8.first).intValue()]);
                                if (((Integer) P8.second).intValue() != -1) {
                                    str8 = ", " + strArr[((Integer) P8.second).intValue()];
                                }
                                sb2.append(str8);
                                sb2.append(")");
                                Log.d(str7, sb2.toString());
                            }
                        } else {
                            i11 = fVar.f146856d;
                        }
                    }
                    switch (i11) {
                        case 1:
                            str3 = str7;
                            i10 = i13;
                            this.f146819f[i15].put(str5, d.a(str6));
                            str7 = str3;
                            break;
                        case 2:
                        case 7:
                            str3 = str7;
                            i10 = i13;
                            this.f146819f[i15].put(str5, d.h(str6));
                            str7 = str3;
                            break;
                        case 3:
                            str3 = str7;
                            i10 = i13;
                            String[] split = str6.split(",", -1);
                            int[] iArr = new int[split.length];
                            for (int i19 = 0; i19 < split.length; i19++) {
                                iArr[i19] = Integer.parseInt(split[i19]);
                            }
                            this.f146819f[i15].put(str5, d.n(iArr, this.f146821h));
                            str7 = str3;
                            break;
                        case 4:
                            str3 = str7;
                            i10 = i13;
                            String[] split2 = str6.split(",", -1);
                            long[] jArr = new long[split2.length];
                            for (int i20 = 0; i20 < split2.length; i20++) {
                                jArr[i20] = Long.parseLong(split2[i20]);
                            }
                            this.f146819f[i15].put(str5, d.j(jArr, this.f146821h));
                            str7 = str3;
                            break;
                        case 5:
                            str3 = str7;
                            String[] split3 = str6.split(",", -1);
                            h[] hVarArr = new h[split3.length];
                            int i21 = 0;
                            while (i21 < split3.length) {
                                String[] split4 = split3[i21].split("/", i16);
                                hVarArr[i21] = new h((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1]));
                                i21++;
                                i16 = -1;
                            }
                            i10 = 1;
                            this.f146819f[i15].put(str5, d.l(hVarArr, this.f146821h));
                            str7 = str3;
                            break;
                        case 6:
                        case 8:
                        case 11:
                        default:
                            str3 = str7;
                            i10 = i13;
                            if (f146796y) {
                                str7 = str3;
                                Log.d(str7, "Data format isn't one of expected formats: " + i11);
                                break;
                            }
                            str7 = str3;
                            break;
                        case 9:
                            str4 = str7;
                            String[] split5 = str6.split(",", -1);
                            int[] iArr2 = new int[split5.length];
                            for (int i22 = 0; i22 < split5.length; i22++) {
                                iArr2[i22] = Integer.parseInt(split5[i22]);
                            }
                            this.f146819f[i15].put(str5, d.e(iArr2, this.f146821h));
                            str7 = str4;
                            i10 = 1;
                            break;
                        case 10:
                            String[] split6 = str6.split(",", -1);
                            h[] hVarArr2 = new h[split6.length];
                            int i23 = i14;
                            while (i23 < split6.length) {
                                String[] split7 = split6[i23].split("/", -1);
                                hVarArr2[i23] = new h((long) Double.parseDouble(split7[i14]), (long) Double.parseDouble(split7[i13]));
                                i23++;
                                str7 = str7;
                                i13 = 1;
                                i14 = 0;
                            }
                            str4 = str7;
                            this.f146819f[i15].put(str5, d.g(hVarArr2, this.f146821h));
                            str7 = str4;
                            i10 = 1;
                            break;
                        case 12:
                            String[] split8 = str6.split(",", -1);
                            double[] dArr = new double[split8.length];
                            for (int i24 = i14; i24 < split8.length; i24++) {
                                dArr[i24] = Double.parseDouble(split8[i24]);
                            }
                            this.f146819f[i15].put(str5, d.c(dArr, this.f146821h));
                            break;
                    }
                    i15++;
                    i13 = i10;
                    i12 = 2;
                    i14 = 0;
                }
            }
            i10 = i13;
            i15++;
            i13 = i10;
            i12 = 2;
            i14 = 0;
        }
    }

    @o0
    public double[] B() {
        String o10 = o(B1);
        String o11 = o(A1);
        String o12 = o(D1);
        String o13 = o(C1);
        if (o10 == null || o11 == null || o12 == null || o13 == null) {
            return null;
        }
        try {
            return new double[]{f(o10, o11), f(o12, o13)};
        } catch (IllegalArgumentException unused) {
            Log.w(f146787x, "Latitude/longitude values are not parsable. " + String.format("latValue=%s, latRef=%s, lngValue=%s, lngRef=%s", o10, o11, o12, o13));
            return null;
        }
    }

    @x0({x0.a.LIBRARY})
    public void B0(long j10) {
        A0(W, f146737q6.format(new Date(j10)));
        A0(f146755t0, Long.toString(j10 % 1000));
    }

    public final int C(BufferedInputStream bufferedInputStream) throws IOException {
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        if (Y(bArr)) {
            return 4;
        }
        if (b0(bArr)) {
            return 9;
        }
        if (X(bArr)) {
            return 12;
        }
        if (Z(bArr)) {
            return 7;
        }
        if (c0(bArr)) {
            return 10;
        }
        if (a0(bArr)) {
            return 13;
        }
        return j0(bArr) ? 14 : 0;
    }

    public void C0(Location location) {
        if (location != null) {
            A0(f146605a2, location.getProvider());
            D0(location.getLatitude(), location.getLongitude());
            z0(location.getAltitude());
            A0(L1, "K");
            A0(M1, new h((double) ((location.getSpeed() * ((float) TimeUnit.HOURS.toSeconds(1))) / 1000.0f)).toString());
            String[] split = f146737q6.format(new Date(location.getTime())).split("\\s+", -1);
            A0(f146621c2, split[0]);
            A0(G1, split[1]);
        }
    }

    public final void D(b bVar) throws IOException {
        G(bVar);
        d dVar = this.f146819f[1].get(f146691l0);
        if (dVar != null) {
            b bVar2 = new b(dVar.f146852d);
            bVar2.f(this.f146821h);
            byte[] bArr = O5;
            byte[] bArr2 = new byte[bArr.length];
            bVar2.readFully(bArr2);
            bVar2.d(0);
            byte[] bArr3 = P5;
            byte[] bArr4 = new byte[bArr3.length];
            bVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                bVar2.d(8);
            } else if (Arrays.equals(bArr4, bArr3)) {
                bVar2.d(12);
            }
            q0(bVar2, 6);
            d dVar2 = this.f146819f[7].get(f146701m2);
            d dVar3 = this.f146819f[7].get(f146709n2);
            if (!(dVar2 == null || dVar3 == null)) {
                this.f146819f[5].put(P, dVar2);
                this.f146819f[5].put(Q, dVar3);
            }
            d dVar4 = this.f146819f[8].get(f146717o2);
            if (dVar4 != null) {
                int[] iArr = (int[]) dVar4.r(this.f146821h);
                if (iArr == null || iArr.length != 4) {
                    Log.w(f146787x, "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
                } else if (iArr[2] > iArr[0] && iArr[3] > iArr[1]) {
                    int i10 = (iArr[2] - iArr[0]) + 1;
                    int i11 = (iArr[3] - iArr[1]) + 1;
                    if (i10 < i11) {
                        int i12 = i10 + i11;
                        i11 = i12 - i11;
                        i10 = i12 - i11;
                    }
                    d m10 = d.m(i10, this.f146821h);
                    d m11 = d.m(i11, this.f146821h);
                    this.f146819f[0].put(f146805z, m10);
                    this.f146819f[0].put(A, m11);
                }
            }
        }
    }

    public void D0(double d10, double d11) {
        if (d10 < -90.0d || d10 > 90.0d || Double.isNaN(d10)) {
            throw new IllegalArgumentException("Latitude value " + d10 + " is not valid.");
        } else if (d11 < -180.0d || d11 > 180.0d || Double.isNaN(d11)) {
            throw new IllegalArgumentException("Longitude value " + d11 + " is not valid.");
        } else {
            A0(A1, d10 >= 0.0d ? "N" : T4);
            A0(B1, e(Math.abs(d10)));
            A0(C1, d11 >= 0.0d ? U4 : V4);
            A0(D1, e(Math.abs(d11)));
        }
    }

    public final void E(b bVar) throws IOException {
        if (f146796y) {
            Log.d(f146787x, "getPngAttributes starting with: " + bVar);
        }
        bVar.f(ByteOrder.BIG_ENDIAN);
        byte[] bArr = V5;
        bVar.skipBytes(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) {
                        if (!Arrays.equals(bArr2, X5)) {
                            throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                        }
                    }
                    if (!Arrays.equals(bArr2, Y5)) {
                        if (Arrays.equals(bArr2, W5)) {
                            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.f146829p = i11;
                                    p0(bArr3, 0);
                                    I0();
                                    return;
                                }
                                throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                            }
                            throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr2));
                        }
                        int i12 = readInt + 4;
                        bVar.skipBytes(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 E0(b bVar) throws IOException {
        HashMap<String, d> hashMap = this.f146819f[4];
        d dVar = hashMap.get(C);
        if (dVar != null) {
            int p10 = dVar.p(this.f146821h);
            this.f146828o = p10;
            if (p10 != 1) {
                if (p10 == 6) {
                    Q(bVar, hashMap);
                    return;
                } else if (p10 != 7) {
                    return;
                }
            }
            if (e0(hashMap)) {
                R(bVar, hashMap);
                return;
            }
            return;
        }
        this.f146828o = 6;
        Q(bVar, hashMap);
    }

    public final void F(b bVar) throws IOException {
        bVar.skipBytes(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        bVar.read(bArr);
        bVar.skipBytes(4);
        bVar.read(bArr2);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        z(bVar, i10, 5);
        bVar.d((long) i11);
        bVar.f(ByteOrder.BIG_ENDIAN);
        int readInt = bVar.readInt();
        if (f146796y) {
            Log.d(f146787x, "numberOfDirectoryEntry: " + readInt);
        }
        for (int i12 = 0; i12 < readInt; i12++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == Q6.f146853a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                d m10 = d.m(readShort, this.f146821h);
                d m11 = d.m(readShort2, this.f146821h);
                this.f146819f[0].put(A, m10);
                this.f146819f[0].put(f146805z, m11);
                if (f146796y) {
                    Log.d(f146787x, "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    public final void G(b bVar) throws IOException {
        d dVar;
        m0(bVar, bVar.available());
        q0(bVar, 0);
        H0(bVar, 0);
        H0(bVar, 5);
        H0(bVar, 4);
        I0();
        if (this.f146817d == 8 && (dVar = this.f146819f[1].get(f146691l0)) != null) {
            b bVar2 = new b(dVar.f146852d);
            bVar2.f(this.f146821h);
            bVar2.d(6);
            q0(bVar2, 9);
            d dVar2 = this.f146819f[9].get(f146643f0);
            if (dVar2 != null) {
                this.f146819f[1].put(f146643f0, dVar2);
            }
        }
    }

    public final void G0(int i10, int i11) throws IOException {
        if (!this.f146819f[i10].isEmpty() && !this.f146819f[i11].isEmpty()) {
            d dVar = this.f146819f[i10].get(A);
            d dVar2 = this.f146819f[i10].get(f146805z);
            d dVar3 = this.f146819f[i11].get(A);
            d dVar4 = this.f146819f[i11].get(f146805z);
            if (dVar == null || dVar2 == null) {
                if (f146796y) {
                    Log.d(f146787x, "First image does not contain valid size information");
                }
            } else if (dVar3 != null && dVar4 != null) {
                int p10 = dVar.p(this.f146821h);
                int p11 = dVar2.p(this.f146821h);
                int p12 = dVar3.p(this.f146821h);
                int p13 = dVar4.p(this.f146821h);
                if (p10 < p12 && p11 < p13) {
                    HashMap<String, d>[] hashMapArr = this.f146819f;
                    HashMap<String, d> hashMap = hashMapArr[i10];
                    hashMapArr[i10] = hashMapArr[i11];
                    hashMapArr[i11] = hashMap;
                }
            } else if (f146796y) {
                Log.d(f146787x, "Second image does not contain valid size information");
            }
        } else if (f146796y) {
            Log.d(f146787x, "Cannot perform swap since only one image data exists");
        }
    }

    public int H() {
        switch (r(E, 1)) {
            case 3:
            case 4:
                return 180;
            case 5:
            case 8:
                return SubsamplingScaleImageView.ORIENTATION_270;
            case 6:
            case 7:
                return 90;
            default:
                return 0;
        }
    }

    public final void H0(b bVar, int i10) throws IOException {
        d dVar;
        d dVar2;
        d dVar3 = this.f146819f[i10].get(f146685k2);
        d dVar4 = this.f146819f[i10].get(f146749s2);
        d dVar5 = this.f146819f[i10].get(f146733q2);
        d dVar6 = this.f146819f[i10].get(f146725p2);
        d dVar7 = this.f146819f[i10].get(f146741r2);
        if (dVar3 != null) {
            if (dVar3.f146849a == 5) {
                h[] hVarArr = (h[]) dVar3.r(this.f146821h);
                if (hVarArr == null || hVarArr.length != 2) {
                    Log.w(f146787x, "Invalid crop size values. cropSize=" + Arrays.toString(hVarArr));
                    return;
                }
                dVar2 = d.k(hVarArr[0], this.f146821h);
                dVar = d.k(hVarArr[1], this.f146821h);
            } else {
                int[] iArr = (int[]) dVar3.r(this.f146821h);
                if (iArr == null || iArr.length != 2) {
                    Log.w(f146787x, "Invalid crop size values. cropSize=" + Arrays.toString(iArr));
                    return;
                }
                dVar2 = d.m(iArr[0], this.f146821h);
                dVar = d.m(iArr[1], this.f146821h);
            }
            this.f146819f[i10].put(f146805z, dVar2);
            this.f146819f[i10].put(A, dVar);
        } else if (dVar4 == null || dVar5 == null || dVar6 == null || dVar7 == null) {
            t0(bVar, i10);
        } else {
            int p10 = dVar4.p(this.f146821h);
            int p11 = dVar6.p(this.f146821h);
            int p12 = dVar7.p(this.f146821h);
            int p13 = dVar5.p(this.f146821h);
            if (p11 > p10 && p12 > p13) {
                d m10 = d.m(p11 - p10, this.f146821h);
                d m11 = d.m(p12 - p13, this.f146821h);
                this.f146819f[i10].put(A, m10);
                this.f146819f[i10].put(f146805z, m11);
            }
        }
    }

    public final void I(b bVar) throws IOException {
        G(bVar);
        if (this.f146819f[0].get(f146765u2) != null) {
            z(bVar, this.f146833t, 5);
        }
        d dVar = this.f146819f[0].get(f146757t2);
        d dVar2 = this.f146819f[1].get(B0);
        if (dVar != null && dVar2 == null) {
            this.f146819f[1].put(B0, dVar);
        }
    }

    public final void I0() throws IOException {
        G0(0, 5);
        G0(0, 4);
        G0(5, 4);
        d dVar = this.f146819f[1].get(f146659h0);
        d dVar2 = this.f146819f[1].get(f146667i0);
        if (!(dVar == null || dVar2 == null)) {
            this.f146819f[0].put(f146805z, dVar);
            this.f146819f[0].put(A, dVar2);
        }
        if (this.f146819f[4].isEmpty() && h0(this.f146819f[5])) {
            HashMap<String, d>[] hashMapArr = this.f146819f;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (!h0(this.f146819f[4])) {
            Log.d(f146787x, "No image meets the size requirements of a thumbnail image.");
        }
    }

    public final void J(b bVar) throws IOException {
        byte[] bArr = f146722o7;
        bVar.skipBytes(bArr.length);
        byte[] bArr2 = new byte[bVar.available()];
        bVar.readFully(bArr2);
        this.f146829p = bArr.length;
        p0(bArr2, 0);
    }

    public final int J0(c cVar) throws IOException {
        f[][] fVarArr = f146650f7;
        int[] iArr = new int[fVarArr.length];
        int[] iArr2 = new int[fVarArr.length];
        for (f fVar : f146658g7) {
            r0(fVar.f146854b);
        }
        r0(f146666h7.f146854b);
        r0(f146674i7.f146854b);
        for (int i10 = 0; i10 < f146650f7.length; i10++) {
            for (Object obj : this.f146819f[i10].entrySet().toArray()) {
                Map.Entry entry = (Map.Entry) obj;
                if (entry.getValue() == null) {
                    this.f146819f[i10].remove(entry.getKey());
                }
            }
        }
        if (!this.f146819f[1].isEmpty()) {
            this.f146819f[0].put(f146658g7[1].f146854b, d.i(0, this.f146821h));
        }
        if (!this.f146819f[2].isEmpty()) {
            this.f146819f[0].put(f146658g7[2].f146854b, d.i(0, this.f146821h));
        }
        if (!this.f146819f[3].isEmpty()) {
            this.f146819f[1].put(f146658g7[3].f146854b, d.i(0, this.f146821h));
        }
        if (this.f146822i) {
            this.f146819f[4].put(f146666h7.f146854b, d.i(0, this.f146821h));
            this.f146819f[4].put(f146674i7.f146854b, d.i((long) this.f146826m, this.f146821h));
        }
        for (int i11 = 0; i11 < f146650f7.length; i11++) {
            int i12 = 0;
            for (Map.Entry<String, d> entry2 : this.f146819f[i11].entrySet()) {
                int s10 = entry2.getValue().s();
                if (s10 > 4) {
                    i12 += s10;
                }
            }
            iArr2[i11] = iArr2[i11] + i12;
        }
        int i13 = 8;
        for (int i14 = 0; i14 < f146650f7.length; i14++) {
            if (!this.f146819f[i14].isEmpty()) {
                iArr[i14] = i13;
                i13 += (this.f146819f[i14].size() * 12) + 2 + 4 + iArr2[i14];
            }
        }
        if (this.f146822i) {
            this.f146819f[4].put(f146666h7.f146854b, d.i((long) i13, this.f146821h));
            this.f146825l = this.f146829p + i13;
            i13 += this.f146826m;
        }
        if (this.f146817d == 4) {
            i13 += 8;
        }
        if (f146796y) {
            for (int i15 = 0; i15 < f146650f7.length; i15++) {
                Log.d(f146787x, String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d", Integer.valueOf(i15), Integer.valueOf(iArr[i15]), Integer.valueOf(this.f146819f[i15].size()), Integer.valueOf(iArr2[i15]), Integer.valueOf(i13)));
            }
        }
        if (!this.f146819f[1].isEmpty()) {
            this.f146819f[0].put(f146658g7[1].f146854b, d.i((long) iArr[1], this.f146821h));
        }
        if (!this.f146819f[2].isEmpty()) {
            this.f146819f[0].put(f146658g7[2].f146854b, d.i((long) iArr[2], this.f146821h));
        }
        if (!this.f146819f[3].isEmpty()) {
            this.f146819f[1].put(f146658g7[3].f146854b, d.i((long) iArr[3], this.f146821h));
        }
        int i16 = this.f146817d;
        if (i16 == 4) {
            cVar.g(i13);
            cVar.write(f146722o7);
        } else if (i16 == 13) {
            cVar.c(i13);
            cVar.write(W5);
        } else if (i16 == 14) {
            cVar.write(f146641e6);
            cVar.c(i13);
        }
        cVar.d(this.f146821h == ByteOrder.BIG_ENDIAN ? f146753s6 : f146745r6);
        cVar.a(this.f146821h);
        cVar.g(42);
        cVar.f(8);
        for (int i17 = 0; i17 < f146650f7.length; i17++) {
            if (!this.f146819f[i17].isEmpty()) {
                cVar.g(this.f146819f[i17].size());
                int size = iArr[i17] + 2 + (this.f146819f[i17].size() * 12) + 4;
                for (Map.Entry<String, d> entry3 : this.f146819f[i17].entrySet()) {
                    int i18 = f146690k7[i17].get(entry3.getKey()).f146853a;
                    d value = entry3.getValue();
                    int s11 = value.s();
                    cVar.g(i18);
                    cVar.g(value.f146849a);
                    cVar.c(value.f146850b);
                    if (s11 > 4) {
                        cVar.f((long) size);
                        size += s11;
                    } else {
                        cVar.write(value.f146852d);
                        if (s11 < 4) {
                            while (s11 < 4) {
                                cVar.b(0);
                                s11++;
                            }
                        }
                    }
                }
                if (i17 != 0 || this.f146819f[4].isEmpty()) {
                    cVar.f(0);
                } else {
                    cVar.f((long) iArr[4]);
                }
                for (Map.Entry<String, d> entry4 : this.f146819f[i17].entrySet()) {
                    byte[] bArr = entry4.getValue().f146852d;
                    if (bArr.length > 4) {
                        cVar.write(bArr, 0, bArr.length);
                    }
                }
            }
        }
        if (this.f146822i) {
            cVar.write(M());
        }
        if (this.f146817d == 14 && i13 % 2 == 1) {
            cVar.b(0);
        }
        cVar.a(ByteOrder.BIG_ENDIAN);
        return i13;
    }

    @o0
    public byte[] K() {
        int i10 = this.f146828o;
        if (i10 == 6 || i10 == 7) {
            return M();
        }
        return null;
    }

    @o0
    public Bitmap L() {
        if (!this.f146822i) {
            return null;
        }
        if (this.f146827n == null) {
            this.f146827n = M();
        }
        int i10 = this.f146828o;
        if (i10 == 6 || i10 == 7) {
            return BitmapFactory.decodeByteArray(this.f146827n, 0, this.f146826m);
        }
        if (i10 == 1) {
            int length = this.f146827n.length / 3;
            int[] iArr = new int[length];
            for (int i11 = 0; i11 < length; i11++) {
                byte[] bArr = this.f146827n;
                int i12 = i11 * 3;
                iArr[i11] = (bArr[i12] << Ascii.DLE) + 0 + (bArr[i12 + 1] << 8) + bArr[i12 + 2];
            }
            d dVar = this.f146819f[4].get(A);
            d dVar2 = this.f146819f[4].get(f146805z);
            if (!(dVar == null || dVar2 == null)) {
                return Bitmap.createBitmap(iArr, dVar2.p(this.f146821h), dVar.p(this.f146821h), Bitmap.Config.ARGB_8888);
            }
        }
        return null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:38:0x0064 A[SYNTHETIC, Splitter:B:38:0x0064] */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x0099  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00b0  */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x00bb  */
    @o0
    public byte[] M() {
        FileDescriptor fileDescriptor;
        Throwable th2;
        InputStream inputStream;
        Exception e10;
        FileDescriptor fileDescriptor2;
        InputStream inputStream2 = null;
        if (!this.f146822i) {
            return null;
        }
        byte[] bArr = this.f146827n;
        if (bArr != null) {
            return bArr;
        }
        try {
            inputStream = this.f146816c;
            if (inputStream != null) {
                try {
                    if (inputStream.markSupported()) {
                        inputStream.reset();
                    } else {
                        Log.d(f146787x, "Cannot read thumbnail from inputstream without mark/reset support");
                        d(inputStream);
                        return null;
                    }
                } catch (Exception e11) {
                    e10 = e11;
                    fileDescriptor = null;
                    try {
                        Log.d(f146787x, "Encountered exception while getting thumbnail", e10);
                        d(inputStream);
                        if (fileDescriptor != null) {
                        }
                        return null;
                    } catch (Throwable th3) {
                        th2 = th3;
                        inputStream2 = inputStream;
                        d(inputStream2);
                        if (fileDescriptor != null) {
                            c(fileDescriptor);
                        }
                        throw th2;
                    }
                } catch (Throwable th4) {
                    th2 = th4;
                    fileDescriptor = null;
                    inputStream2 = inputStream;
                    d(inputStream2);
                    if (fileDescriptor != null) {
                    }
                    throw th2;
                }
            } else if (this.f146814a != null) {
                inputStream = new FileInputStream(this.f146814a);
            } else if (Build.VERSION.SDK_INT < 21 || (fileDescriptor2 = this.f146815b) == null) {
                inputStream = null;
                fileDescriptor = null;
                if (inputStream != null) {
                    try {
                        if (inputStream.skip((long) this.f146825l) == ((long) this.f146825l)) {
                            byte[] bArr2 = new byte[this.f146826m];
                            if (inputStream.read(bArr2) == this.f146826m) {
                                this.f146827n = bArr2;
                                d(inputStream);
                                if (fileDescriptor != null) {
                                    c(fileDescriptor);
                                }
                                return bArr2;
                            }
                            throw new IOException("Corrupted image");
                        }
                        throw new IOException("Corrupted image");
                    } catch (Exception e12) {
                        e10 = e12;
                        Log.d(f146787x, "Encountered exception while getting thumbnail", e10);
                        d(inputStream);
                        if (fileDescriptor != null) {
                        }
                        return null;
                    }
                } else {
                    throw new FileNotFoundException();
                }
            } else {
                FileDescriptor dup = Os.dup(fileDescriptor2);
                try {
                    Os.lseek(dup, 0, OsConstants.SEEK_SET);
                    fileDescriptor = dup;
                    inputStream = new FileInputStream(dup);
                    if (inputStream != null) {
                    }
                } catch (Exception e13) {
                    e10 = e13;
                    fileDescriptor = dup;
                    inputStream = null;
                    Log.d(f146787x, "Encountered exception while getting thumbnail", e10);
                    d(inputStream);
                    if (fileDescriptor != null) {
                    }
                    return null;
                } catch (Throwable th5) {
                    th2 = th5;
                    fileDescriptor = dup;
                    d(inputStream2);
                    if (fileDescriptor != null) {
                    }
                    throw th2;
                }
            }
            fileDescriptor = null;
            if (inputStream != null) {
            }
        } catch (Exception e14) {
            inputStream = null;
            e10 = e14;
            fileDescriptor = null;
            Log.d(f146787x, "Encountered exception while getting thumbnail", e10);
            d(inputStream);
            if (fileDescriptor != null) {
                c(fileDescriptor);
            }
            return null;
        } catch (Throwable th6) {
            th2 = th6;
            fileDescriptor = null;
            d(inputStream2);
            if (fileDescriptor != null) {
            }
            throw th2;
        }
    }

    @o0
    public long[] N() {
        if (this.f146835v) {
            throw new IllegalStateException("The underlying file has been modified since being parsed");
        } else if (!this.f146822i) {
            return null;
        } else {
            if (this.f146823j && !this.f146824k) {
                return null;
            }
            return new long[]{(long) this.f146825l, (long) this.f146826m};
        }
    }

    public final void O(b bVar) throws IOException {
        if (f146796y) {
            Log.d(f146787x, "getWebpAttributes starting with: " + bVar);
        }
        bVar.f(ByteOrder.LITTLE_ENDIAN);
        bVar.skipBytes(f146617b6.length);
        int readInt = bVar.readInt() + 8;
        int skipBytes = bVar.skipBytes(f146625c6.length) + 8;
        while (true) {
            try {
                byte[] bArr = new byte[4];
                if (bVar.read(bArr) == 4) {
                    int readInt2 = bVar.readInt();
                    int i10 = skipBytes + 4 + 4;
                    if (Arrays.equals(f146641e6, bArr)) {
                        byte[] bArr2 = new byte[readInt2];
                        if (bVar.read(bArr2) == readInt2) {
                            this.f146829p = i10;
                            p0(bArr2, 0);
                            this.f146829p = i10;
                            return;
                        }
                        throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr));
                    }
                    if (readInt2 % 2 == 1) {
                        readInt2++;
                    }
                    int i11 = i10 + readInt2;
                    if (i11 != readInt) {
                        if (i11 <= readInt) {
                            int skipBytes2 = bVar.skipBytes(readInt2);
                            if (skipBytes2 == readInt2) {
                                skipBytes = i10 + skipBytes2;
                            } else {
                                throw new IOException("Encountered WebP file with invalid chunk size");
                            }
                        } else {
                            throw new IOException("Encountered WebP file with invalid chunk size");
                        }
                    } else {
                        return;
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void Q(b bVar, HashMap hashMap) throws IOException {
        d dVar = (d) hashMap.get(P);
        d dVar2 = (d) hashMap.get(Q);
        if (dVar != null && dVar2 != null) {
            int p10 = dVar.p(this.f146821h);
            int p11 = dVar2.p(this.f146821h);
            if (this.f146817d == 7) {
                p10 += this.f146830q;
            }
            int min = Math.min(p11, bVar.a() - p10);
            if (p10 > 0 && min > 0) {
                this.f146822i = true;
                int i10 = this.f146829p + p10;
                this.f146825l = i10;
                this.f146826m = min;
                if (this.f146814a == null && this.f146816c == null && this.f146815b == null) {
                    byte[] bArr = new byte[min];
                    bVar.d((long) i10);
                    bVar.readFully(bArr);
                    this.f146827n = bArr;
                }
            }
            if (f146796y) {
                Log.d(f146787x, "Setting thumbnail attributes with offset: " + p10 + ", length: " + min);
            }
        }
    }

    public final void R(b bVar, HashMap hashMap) throws IOException {
        d dVar = (d) hashMap.get(M);
        d dVar2 = (d) hashMap.get(O);
        if (dVar != null && dVar2 != null) {
            long[] g10 = g(dVar.r(this.f146821h));
            long[] g11 = g(dVar2.r(this.f146821h));
            if (g10 == null || g10.length == 0) {
                Log.w(f146787x, "stripOffsets should not be null or have zero length.");
            } else if (g11 == null || g11.length == 0) {
                Log.w(f146787x, "stripByteCounts should not be null or have zero length.");
            } else if (g10.length != g11.length) {
                Log.w(f146787x, "stripOffsets and stripByteCounts should have same length.");
            } else {
                long j10 = 0;
                for (long j11 : g11) {
                    j10 += j11;
                }
                int i10 = (int) j10;
                byte[] bArr = new byte[i10];
                this.f146824k = true;
                this.f146823j = true;
                this.f146822i = true;
                int i11 = 0;
                int i12 = 0;
                for (int i13 = 0; i13 < g10.length; i13++) {
                    int i14 = (int) g10[i13];
                    int i15 = (int) g11[i13];
                    if (i13 < g10.length - 1 && ((long) (i14 + i15)) != g10[i13 + 1]) {
                        this.f146824k = false;
                    }
                    int i16 = i14 - i11;
                    if (i16 < 0) {
                        Log.d(f146787x, "Invalid strip offset value");
                    }
                    bVar.d((long) i16);
                    int i17 = i11 + i16;
                    byte[] bArr2 = new byte[i15];
                    bVar.read(bArr2);
                    i11 = i17 + i15;
                    System.arraycopy(bArr2, 0, bArr, i12, i15);
                    i12 += i15;
                }
                this.f146827n = bArr;
                if (this.f146824k) {
                    this.f146825l = ((int) g10[0]) + this.f146829p;
                    this.f146826m = i10;
                }
            }
        }
    }

    public boolean S(@m0 String str) {
        return w(str) != null;
    }

    public boolean T() {
        return this.f146822i;
    }

    public final void U(String str) throws IOException {
        Throwable th2;
        Objects.requireNonNull(str, "filename cannot be null");
        FileInputStream fileInputStream = null;
        this.f146816c = null;
        this.f146814a = str;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(str);
            try {
                if (d0(fileInputStream2.getFD())) {
                    this.f146815b = fileInputStream2.getFD();
                } else {
                    this.f146815b = null;
                }
                k0(fileInputStream2);
                d(fileInputStream2);
            } catch (Throwable th3) {
                th2 = th3;
                fileInputStream = fileInputStream2;
                d(fileInputStream);
                throw th2;
            }
        } catch (Throwable th4) {
            th2 = th4;
            d(fileInputStream);
            throw th2;
        }
    }

    public boolean W() {
        int r10 = r(E, 1);
        return r10 == 2 || r10 == 7 || r10 == 4 || r10 == 5;
    }

    /* JADX WARNING: Removed duplicated region for block: B:52:0x0092 A[Catch:{ all -> 0x008b }] */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x009b  */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x00a1  */
    public final boolean X(byte[] bArr) throws IOException {
        Throwable th2;
        Exception e10;
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                long readInt = (long) bVar2.readInt();
                byte[] bArr2 = new byte[4];
                bVar2.read(bArr2);
                if (!Arrays.equals(bArr2, J5)) {
                    bVar2.close();
                    return false;
                }
                long j10 = 16;
                if (readInt == 1) {
                    readInt = bVar2.readLong();
                    if (readInt < 16) {
                        bVar2.close();
                        return false;
                    }
                } else {
                    j10 = 8;
                }
                if (readInt > ((long) bArr.length)) {
                    readInt = (long) bArr.length;
                }
                long j11 = readInt - j10;
                if (j11 < 8) {
                    bVar2.close();
                    return false;
                }
                byte[] bArr3 = new byte[4];
                boolean z10 = false;
                boolean z11 = false;
                for (long j12 = 0; j12 < j11 / 4; j12++) {
                    if (bVar2.read(bArr3) != 4) {
                        bVar2.close();
                        return false;
                    }
                    if (j12 != 1) {
                        if (Arrays.equals(bArr3, K5)) {
                            z10 = true;
                        } else if (Arrays.equals(bArr3, L5)) {
                            z11 = true;
                        }
                        if (z10 && z11) {
                            bVar2.close();
                            return true;
                        }
                    }
                }
                bVar2.close();
                return false;
            } catch (Exception e11) {
                e10 = e11;
                bVar = bVar2;
                try {
                    if (f146796y) {
                    }
                    if (bVar != null) {
                    }
                    return false;
                } catch (Throwable th3) {
                    th2 = th3;
                    if (bVar != null) {
                    }
                    throw th2;
                }
            } catch (Throwable th4) {
                th2 = th4;
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                throw th2;
            }
        } catch (Exception e12) {
            e10 = e12;
            if (f146796y) {
                Log.d(f146787x, "Exception parsing HEIF file type box.", e10);
            }
            if (bVar != null) {
                bVar.close();
            }
            return false;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x0029  */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x002f  */
    public final boolean Z(byte[] bArr) throws IOException {
        Throwable th2;
        boolean z10 = false;
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder o02 = o0(bVar2);
                this.f146821h = o02;
                bVar2.f(o02);
                short readShort = bVar2.readShort();
                if (readShort == 20306 || readShort == 21330) {
                    z10 = true;
                }
                bVar2.close();
                return z10;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                }
                return false;
            } catch (Throwable th3) {
                th2 = th3;
                bVar = bVar2;
                if (bVar != null) {
                }
                throw th2;
            }
        } catch (Exception unused2) {
            if (bVar != null) {
                bVar.close();
            }
            return false;
        } catch (Throwable th4) {
            th2 = th4;
            if (bVar != null) {
                bVar.close();
            }
            throw th2;
        }
    }

    public final void a() {
        String o10 = o(f146715o0);
        if (o10 != null && o(W) == null) {
            this.f146819f[0].put(W, d.h(o10));
        }
        if (o(f146805z) == null) {
            this.f146819f[0].put(f146805z, d.i(0, this.f146821h));
        }
        if (o(A) == null) {
            this.f146819f[0].put(A, d.i(0, this.f146821h));
        }
        if (o(E) == null) {
            this.f146819f[0].put(E, d.i(0, this.f146821h));
        }
        if (o(Q0) == null) {
            this.f146819f[1].put(Q0, d.i(0, this.f146821h));
        }
    }

    public final boolean a0(byte[] bArr) throws IOException {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = V5;
            if (i10 >= bArr2.length) {
                return true;
            }
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
            i10++;
        }
    }

    public final boolean b0(byte[] bArr) throws IOException {
        byte[] bytes = G5.getBytes(Charset.defaultCharset());
        for (int i10 = 0; i10 < bytes.length; i10++) {
            if (bArr[i10] != bytes[i10]) {
                return false;
            }
        }
        return true;
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x0025  */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x002b  */
    public final boolean c0(byte[] bArr) throws IOException {
        Throwable th2;
        boolean z10 = false;
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder o02 = o0(bVar2);
                this.f146821h = o02;
                bVar2.f(o02);
                if (bVar2.readShort() == 85) {
                    z10 = true;
                }
                bVar2.close();
                return z10;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                }
                return false;
            } catch (Throwable th3) {
                th2 = th3;
                bVar = bVar2;
                if (bVar != null) {
                }
                throw th2;
            }
        } catch (Exception unused2) {
            if (bVar != null) {
                bVar.close();
            }
            return false;
        } catch (Throwable th4) {
            th2 = th4;
            if (bVar != null) {
                bVar.close();
            }
            throw th2;
        }
    }

    public final String e(double d10) {
        long j10 = (long) d10;
        double d11 = d10 - ((double) j10);
        long j11 = (long) (d11 * 60.0d);
        long round = Math.round((d11 - (((double) j11) / 60.0d)) * 3600.0d * 1.0E7d);
        return j10 + "/1," + j11 + "/1," + round + "/10000000";
    }

    public final boolean e0(HashMap hashMap) throws IOException {
        d dVar;
        int p10;
        d dVar2 = (d) hashMap.get(B);
        if (dVar2 != null) {
            int[] iArr = (int[]) dVar2.r(this.f146821h);
            int[] iArr2 = f146760t5;
            if (Arrays.equals(iArr2, iArr)) {
                return true;
            }
            if (this.f146817d == 3 && (dVar = (d) hashMap.get(D)) != null && (((p10 = dVar.p(this.f146821h)) == 1 && Arrays.equals(iArr, f146776v5)) || (p10 == 6 && Arrays.equals(iArr, iArr2)))) {
                return true;
            }
        }
        if (!f146796y) {
            return false;
        }
        Log.d(f146787x, "Unsupported data type value");
        return false;
    }

    public final boolean f0() {
        if (!this.f146834u) {
            return false;
        }
        int i10 = this.f146817d;
        return i10 == 4 || i10 == 13 || i10 == 14;
    }

    public final boolean h0(HashMap hashMap) throws IOException {
        d dVar = (d) hashMap.get(A);
        d dVar2 = (d) hashMap.get(f146805z);
        if (dVar == null || dVar2 == null) {
            return false;
        }
        return dVar.p(this.f146821h) <= 512 && dVar2.p(this.f146821h) <= 512;
    }

    public boolean i0() {
        if (!this.f146822i) {
            return false;
        }
        int i10 = this.f146828o;
        if (i10 == 6 || i10 == 7) {
            return true;
        }
        return false;
    }

    public final void j(b bVar, c cVar, byte[] bArr, byte[] bArr2) throws IOException {
        String str;
        while (true) {
            byte[] bArr3 = new byte[4];
            if (bVar.read(bArr3) != 4) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Encountered invalid length while copying WebP chunks up tochunk type ");
                Charset charset = f146714n7;
                sb2.append(new String(bArr, charset));
                if (bArr2 == null) {
                    str = "";
                } else {
                    str = " or " + new String(bArr2, charset);
                }
                sb2.append(str);
                throw new IOException(sb2.toString());
            }
            k(bVar, cVar, bArr3);
            if (Arrays.equals(bArr3, bArr)) {
                return;
            }
            if (bArr2 != null && Arrays.equals(bArr3, bArr2)) {
                return;
            }
        }
    }

    public final boolean j0(byte[] bArr) throws IOException {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = f146617b6;
            if (i10 >= bArr2.length) {
                int i11 = 0;
                while (true) {
                    byte[] bArr3 = f146625c6;
                    if (i11 >= bArr3.length) {
                        return true;
                    }
                    if (bArr[f146617b6.length + i11 + 4] != bArr3[i11]) {
                        return false;
                    }
                    i11++;
                }
            } else if (bArr[i10] != bArr2[i10]) {
                return false;
            } else {
                i10++;
            }
        }
    }

    public final void k(b bVar, c cVar, byte[] bArr) throws IOException {
        int readInt = bVar.readInt();
        cVar.write(bArr);
        cVar.c(readInt);
        if (readInt % 2 == 1) {
            readInt++;
        }
        i(bVar, cVar, readInt);
    }

    public final void k0(@m0 InputStream inputStream) {
        Objects.requireNonNull(inputStream, "inputstream shouldn't be null");
        for (int i10 = 0; i10 < f146650f7.length; i10++) {
            try {
                this.f146819f[i10] = new HashMap<>();
            } catch (IOException e10) {
                this.f146834u = false;
                boolean z10 = f146796y;
                if (z10) {
                    Log.w(f146787x, "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 (!z10) {
                    return;
                }
            } catch (Throwable th2) {
                a();
                if (f146796y) {
                    n0();
                }
                throw th2;
            }
        }
        if (!this.f146818e) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            this.f146817d = C(bufferedInputStream);
            inputStream = bufferedInputStream;
        }
        b bVar = new b(inputStream);
        if (!this.f146818e) {
            switch (this.f146817d) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    G(bVar);
                    break;
                case 4:
                    z(bVar, 0, 0);
                    break;
                case 7:
                    D(bVar);
                    break;
                case 9:
                    F(bVar);
                    break;
                case 10:
                    I(bVar);
                    break;
                case 12:
                    y(bVar);
                    break;
                case 13:
                    E(bVar);
                    break;
                case 14:
                    O(bVar);
                    break;
            }
        } else {
            J(bVar);
        }
        E0(bVar);
        this.f146834u = true;
        a();
        if (!f146796y) {
            return;
        }
        n0();
    }

    public void l() {
        int i10 = 1;
        switch (r(E, 1)) {
            case 1:
                i10 = 2;
                break;
            case 2:
                break;
            case 3:
                i10 = 4;
                break;
            case 4:
                i10 = 3;
                break;
            case 5:
                i10 = 6;
                break;
            case 6:
                i10 = 5;
                break;
            case 7:
                i10 = 8;
                break;
            case 8:
                i10 = 7;
                break;
            default:
                i10 = 0;
                break;
        }
        A0(E, Integer.toString(i10));
    }

    public void m() {
        int i10 = 1;
        switch (r(E, 1)) {
            case 1:
                i10 = 4;
                break;
            case 2:
                i10 = 3;
                break;
            case 3:
                i10 = 2;
                break;
            case 4:
                break;
            case 5:
                i10 = 8;
                break;
            case 6:
                i10 = 7;
                break;
            case 7:
                i10 = 6;
                break;
            case 8:
                i10 = 5;
                break;
            default:
                i10 = 0;
                break;
        }
        A0(E, Integer.toString(i10));
    }

    public final void m0(b bVar, int i10) throws IOException {
        ByteOrder o02 = o0(bVar);
        this.f146821h = o02;
        bVar.f(o02);
        int readUnsignedShort = bVar.readUnsignedShort();
        int i11 = this.f146817d;
        if (i11 == 7 || i11 == 10 || readUnsignedShort == 42) {
            int readInt = bVar.readInt();
            if (readInt < 8 || readInt >= i10) {
                throw new IOException("Invalid first Ifd offset: " + readInt);
            }
            int i12 = readInt - 8;
            if (i12 > 0 && bVar.skipBytes(i12) != i12) {
                throw new IOException("Couldn't jump to first Ifd: " + i12);
            }
            return;
        }
        throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
    }

    public double n(double d10) {
        double q10 = q(F1, -1.0d);
        int i10 = -1;
        int r10 = r(E1, -1);
        if (q10 < 0.0d || r10 < 0) {
            return d10;
        }
        if (r10 != 1) {
            i10 = 1;
        }
        return q10 * ((double) i10);
    }

    public final void n0() {
        for (int i10 = 0; i10 < this.f146819f.length; i10++) {
            Log.d(f146787x, "The size of tag group[" + i10 + "]: " + this.f146819f[i10].size());
            for (Map.Entry<String, d> entry : this.f146819f[i10].entrySet()) {
                d value = entry.getValue();
                Log.d(f146787x, "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.q(this.f146821h) + "'");
            }
        }
    }

    @o0
    public String o(@m0 String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        d w10 = w(str);
        if (w10 != null) {
            if (!f146698l7.contains(str)) {
                return w10.q(this.f146821h);
            }
            if (str.equals(G1)) {
                int i10 = w10.f146849a;
                if (i10 == 5 || i10 == 10) {
                    h[] hVarArr = (h[]) w10.r(this.f146821h);
                    if (hVarArr == null || hVarArr.length != 3) {
                        Log.w(f146787x, "Invalid GPS Timestamp array. array=" + Arrays.toString(hVarArr));
                        return null;
                    }
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) hVarArr[0].f146857a) / ((float) hVarArr[0].f146858b))), Integer.valueOf((int) (((float) hVarArr[1].f146857a) / ((float) hVarArr[1].f146858b))), Integer.valueOf((int) (((float) hVarArr[2].f146857a) / ((float) hVarArr[2].f146858b))));
                }
                Log.w(f146787x, "GPS Timestamp format is not rational. format=" + w10.f146849a);
                return null;
            }
            try {
                return Double.toString(w10.o(this.f146821h));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public final ByteOrder o0(b bVar) throws IOException {
        short readShort = bVar.readShort();
        if (readShort == 18761) {
            if (f146796y) {
                Log.d(f146787x, "readExifSegment: Byte Align II");
            }
            return ByteOrder.LITTLE_ENDIAN;
        } else if (readShort == 19789) {
            if (f146796y) {
                Log.d(f146787x, "readExifSegment: Byte Align MM");
            }
            return ByteOrder.BIG_ENDIAN;
        } else {
            throw new IOException("Invalid byte order: " + Integer.toHexString(readShort));
        }
    }

    @o0
    public byte[] p(@m0 String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        d w10 = w(str);
        if (w10 != null) {
            return w10.f146852d;
        }
        return null;
    }

    public final void p0(byte[] bArr, int i10) throws IOException {
        b bVar = new b(bArr);
        m0(bVar, bArr.length);
        q0(bVar, i10);
    }

    public double q(@m0 String str, double d10) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        d w10 = w(str);
        if (w10 == null) {
            return d10;
        }
        try {
            return w10.o(this.f146821h);
        } catch (NumberFormatException unused) {
            return d10;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:109:0x02e3  */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x0145  */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x014c  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x027f  */
    public final void q0(b bVar, int i10) throws IOException {
        short s10;
        String str;
        boolean z10;
        long j10;
        short s11;
        long j11;
        f fVar;
        int i11;
        int i12;
        int i13;
        long j12;
        int i14;
        int i15 = i10;
        this.f146820g.add(Integer.valueOf(bVar.f146845d));
        if (bVar.f146845d + 2 <= bVar.f146844c) {
            short readShort = bVar.readShort();
            boolean z11 = f146796y;
            String str2 = f146787x;
            if (z11) {
                Log.d(str2, "numberOfDirectoryEntry: " + ((int) readShort));
            }
            if (bVar.f146845d + (readShort * 12) <= bVar.f146844c && readShort > 0) {
                char c10 = 0;
                short s12 = 0;
                while (s12 < readShort) {
                    int readUnsignedShort = bVar.readUnsignedShort();
                    int readUnsignedShort2 = bVar.readUnsignedShort();
                    int readInt = bVar.readInt();
                    long b10 = ((long) bVar.b()) + 4;
                    f fVar2 = f146682j7[i15].get(Integer.valueOf(readUnsignedShort));
                    boolean z12 = f146796y;
                    if (z12) {
                        Object[] objArr = new Object[5];
                        objArr[c10] = Integer.valueOf(i10);
                        objArr[1] = Integer.valueOf(readUnsignedShort);
                        objArr[2] = fVar2 != null ? fVar2.f146854b : null;
                        objArr[3] = Integer.valueOf(readUnsignedShort2);
                        objArr[4] = Integer.valueOf(readInt);
                        Log.d(str2, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
                    }
                    if (fVar2 != null) {
                        if (readUnsignedShort2 > 0) {
                            int[] iArr = J6;
                            if (readUnsignedShort2 < iArr.length) {
                                if (fVar2.a(readUnsignedShort2)) {
                                    if (readUnsignedShort2 == 7) {
                                        readUnsignedShort2 = fVar2.f146855c;
                                    }
                                    str = str2;
                                    s10 = s12;
                                    j10 = ((long) readInt) * ((long) iArr[readUnsignedShort2]);
                                    if (j10 < 0 || j10 > 2147483647L) {
                                        if (z12) {
                                            Log.d(str, "Skip the tag entry since the number of components is invalid: " + readInt);
                                        }
                                        z10 = false;
                                        if (z10) {
                                            bVar.d(b10);
                                            s11 = readShort;
                                        } else {
                                            if (j10 > 4) {
                                                int readInt2 = bVar.readInt();
                                                s11 = readShort;
                                                if (z12) {
                                                    StringBuilder sb2 = new StringBuilder();
                                                    i13 = readUnsignedShort2;
                                                    sb2.append("seek to data offset: ");
                                                    sb2.append(readInt2);
                                                    Log.d(str, sb2.toString());
                                                } else {
                                                    i13 = readUnsignedShort2;
                                                }
                                                int i16 = this.f146817d;
                                                if (i16 == 7) {
                                                    if (f146691l0.equals(fVar2.f146854b)) {
                                                        this.f146830q = readInt2;
                                                    } else if (i15 == 6 && f146693l2.equals(fVar2.f146854b)) {
                                                        this.f146831r = readInt2;
                                                        this.f146832s = readInt;
                                                        d m10 = d.m(6, this.f146821h);
                                                        i12 = readInt;
                                                        d i17 = d.i((long) this.f146831r, this.f146821h);
                                                        i11 = readUnsignedShort;
                                                        d i18 = d.i((long) this.f146832s, this.f146821h);
                                                        this.f146819f[4].put(C, m10);
                                                        this.f146819f[4].put(P, i17);
                                                        this.f146819f[4].put(Q, i18);
                                                    }
                                                    i11 = readUnsignedShort;
                                                    i12 = readInt;
                                                } else {
                                                    i11 = readUnsignedShort;
                                                    i12 = readInt;
                                                    if (i16 == 10 && f146765u2.equals(fVar2.f146854b)) {
                                                        this.f146833t = readInt2;
                                                    }
                                                }
                                                long j13 = (long) readInt2;
                                                fVar = fVar2;
                                                j11 = j10;
                                                if (j13 + j10 <= ((long) bVar.f146844c)) {
                                                    bVar.d(j13);
                                                } else {
                                                    if (z12) {
                                                        Log.d(str, "Skip the tag entry since data offset is invalid: " + readInt2);
                                                    }
                                                    bVar.d(b10);
                                                }
                                            } else {
                                                s11 = readShort;
                                                fVar = fVar2;
                                                j11 = j10;
                                                i11 = readUnsignedShort;
                                                i13 = readUnsignedShort2;
                                                i12 = readInt;
                                            }
                                            Integer num = f146706m7.get(Integer.valueOf(i11));
                                            if (z12) {
                                                StringBuilder sb3 = new StringBuilder();
                                                sb3.append("nextIfdType: ");
                                                sb3.append(num);
                                                sb3.append(" byteCount: ");
                                                j12 = j11;
                                                sb3.append(j12);
                                                Log.d(str, sb3.toString());
                                            } else {
                                                j12 = j11;
                                            }
                                            if (num != null) {
                                                long j14 = -1;
                                                if (i13 != 3) {
                                                    if (i13 == 4) {
                                                        j14 = bVar.c();
                                                    } else if (i13 == 8) {
                                                        i14 = bVar.readShort();
                                                    } else if (i13 == 9 || i13 == 13) {
                                                        i14 = bVar.readInt();
                                                    }
                                                    if (z12) {
                                                        Log.d(str, String.format("Offset: %d, tagName: %s", Long.valueOf(j14), fVar.f146854b));
                                                    }
                                                    if (j14 > 0 || j14 >= ((long) bVar.f146844c)) {
                                                        if (z12) {
                                                            Log.d(str, "Skip jump into the IFD since its offset is invalid: " + j14);
                                                        }
                                                    } else if (!this.f146820g.contains(Integer.valueOf((int) j14))) {
                                                        bVar.d(j14);
                                                        q0(bVar, num.intValue());
                                                    } else if (z12) {
                                                        Log.d(str, "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j14 + ")");
                                                    }
                                                    bVar.d(b10);
                                                } else {
                                                    i14 = bVar.readUnsignedShort();
                                                }
                                                j14 = (long) i14;
                                                if (z12) {
                                                }
                                                if (j14 > 0) {
                                                }
                                                if (z12) {
                                                }
                                                bVar.d(b10);
                                            } else {
                                                int b11 = bVar.b() + this.f146829p;
                                                byte[] bArr = new byte[((int) j12)];
                                                bVar.readFully(bArr);
                                                d dVar = new d(i13, i12, (long) b11, bArr);
                                                this.f146819f[i10].put(fVar.f146854b, dVar);
                                                if (f146677j2.equals(fVar.f146854b)) {
                                                    this.f146817d = 3;
                                                }
                                                if (((Y.equals(fVar.f146854b) || "Model".equals(fVar.f146854b)) && dVar.q(this.f146821h).contains(T5)) || (C.equals(fVar.f146854b) && dVar.p(this.f146821h) == 65535)) {
                                                    this.f146817d = 8;
                                                }
                                                if (((long) bVar.b()) != b10) {
                                                    bVar.d(b10);
                                                }
                                            }
                                        }
                                        s12 = (short) (s10 + 1);
                                        i15 = i10;
                                        str2 = str;
                                        readShort = s11;
                                        c10 = 0;
                                    } else {
                                        z10 = true;
                                        if (z10) {
                                        }
                                        s12 = (short) (s10 + 1);
                                        i15 = i10;
                                        str2 = str;
                                        readShort = s11;
                                        c10 = 0;
                                    }
                                } else if (z12) {
                                    Log.d(str2, "Skip the tag entry since data format (" + I6[readUnsignedShort2] + ") is unexpected for tag: " + fVar2.f146854b);
                                }
                            }
                        }
                        str = str2;
                        s10 = s12;
                        if (z12) {
                            Log.d(str, "Skip the tag entry since data format is invalid: " + readUnsignedShort2);
                        }
                        j10 = 0;
                        z10 = false;
                        if (z10) {
                        }
                        s12 = (short) (s10 + 1);
                        i15 = i10;
                        str2 = str;
                        readShort = s11;
                        c10 = 0;
                    } else if (z12) {
                        Log.d(str2, "Skip the tag entry since tag number is not defined: " + readUnsignedShort);
                    }
                    str = str2;
                    s10 = s12;
                    j10 = 0;
                    z10 = false;
                    if (z10) {
                    }
                    s12 = (short) (s10 + 1);
                    i15 = i10;
                    str2 = str;
                    readShort = s11;
                    c10 = 0;
                }
                if (bVar.b() + 4 <= bVar.f146844c) {
                    int readInt3 = bVar.readInt();
                    boolean z13 = f146796y;
                    if (z13) {
                        Log.d(str2, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
                    }
                    long j15 = (long) readInt3;
                    if (j15 <= 0 || readInt3 >= bVar.f146844c) {
                        if (z13) {
                            Log.d(str2, "Stop reading file since a wrong offset may cause an infinite loop: " + readInt3);
                        }
                    } else if (!this.f146820g.contains(Integer.valueOf(readInt3))) {
                        bVar.d(j15);
                        if (this.f146819f[4].isEmpty()) {
                            q0(bVar, 4);
                        } else if (this.f146819f[5].isEmpty()) {
                            q0(bVar, 5);
                        }
                    } else if (z13) {
                        Log.d(str2, "Stop reading file since re-reading an IFD may cause an infinite loop: " + readInt3);
                    }
                }
            }
        }
    }

    public int r(@m0 String str, int i10) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        d w10 = w(str);
        if (w10 == null) {
            return i10;
        }
        try {
            return w10.p(this.f146821h);
        } catch (NumberFormatException unused) {
            return i10;
        }
    }

    public final void r0(String str) {
        for (int i10 = 0; i10 < f146650f7.length; i10++) {
            this.f146819f[i10].remove(str);
        }
    }

    @o0
    public long[] s(@m0 String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        if (!this.f146835v) {
            d w10 = w(str);
            if (w10 == null) {
                return null;
            }
            return new long[]{w10.f146851c, (long) w10.f146852d.length};
        }
        throw new IllegalStateException("The underlying file has been modified since being parsed");
    }

    public void s0() {
        A0(E, Integer.toString(1));
    }

    @x0({x0.a.LIBRARY})
    public long t() {
        return l0(o(W), o(f146755t0));
    }

    public final void t0(b bVar, int i10) throws IOException {
        d dVar;
        d dVar2 = this.f146819f[i10].get(A);
        d dVar3 = this.f146819f[i10].get(f146805z);
        if ((dVar2 == null || dVar3 == null) && (dVar = this.f146819f[i10].get(P)) != null) {
            z(bVar, dVar.p(this.f146821h), i10);
        }
    }

    @x0({x0.a.LIBRARY})
    public long u() {
        return l0(o(f146723p0), o(f146771v0));
    }

    public void u0(int i10) {
        if (i10 % 90 == 0) {
            int r10 = r(E, 1);
            List<Integer> list = O2;
            int i11 = 0;
            if (list.contains(Integer.valueOf(r10))) {
                int indexOf = (list.indexOf(Integer.valueOf(r10)) + (i10 / 90)) % 4;
                if (indexOf < 0) {
                    i11 = 4;
                }
                i11 = list.get(indexOf + i11).intValue();
            } else {
                List<Integer> list2 = P2;
                if (list2.contains(Integer.valueOf(r10))) {
                    int indexOf2 = (list2.indexOf(Integer.valueOf(r10)) + (i10 / 90)) % 4;
                    if (indexOf2 < 0) {
                        i11 = 4;
                    }
                    i11 = list2.get(indexOf2 + i11).intValue();
                }
            }
            A0(E, Integer.toString(i11));
            return;
        }
        throw new IllegalArgumentException("degree should be a multiple of 90");
    }

    @x0({x0.a.LIBRARY})
    public long v() {
        return l0(o(f146715o0), o(f146763u0));
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r7v15, types: [java.io.OutputStream, java.io.FileOutputStream] */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x00b8 A[Catch:{ Exception -> 0x0113, all -> 0x0110 }] */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x00c0 A[Catch:{ Exception -> 0x0113, all -> 0x0110 }] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00e5 A[Catch:{ Exception -> 0x0106, all -> 0x0104 }] */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x00e9 A[Catch:{ Exception -> 0x0106, all -> 0x0104 }] */
    /* JADX WARNING: Removed duplicated region for block: B:80:0x0119 A[Catch:{ all -> 0x0142 }] */
    /* JADX WARNING: Unknown variable types count: 1 */
    public void v0() throws IOException {
        Closeable closeable;
        Throwable th2;
        Closeable closeable2;
        Exception e10;
        FileInputStream fileInputStream;
        FileInputStream fileInputStream2;
        File file;
        BufferedOutputStream bufferedOutputStream;
        Throwable th3;
        Exception e11;
        FileOutputStream fileOutputStream;
        BufferedInputStream bufferedInputStream;
        int i10;
        FileDescriptor fileDescriptor;
        Closeable closeable3;
        Closeable closeable4;
        ?? fileOutputStream2;
        if (!f0()) {
            throw new IOException("ExifInterface only supports saving attributes on JPEG, PNG, or WebP formats.");
        } else if (this.f146815b == null && this.f146814a == null) {
            throw new IOException("ExifInterface does not support saving attributes for the current input.");
        } else {
            this.f146835v = true;
            this.f146827n = K();
            InputStream inputStream = null;
            File file2 = this.f146814a != null ? new File(this.f146814a) : null;
            try {
                if (this.f146814a != null) {
                    file = new File(this.f146814a + ".tmp");
                    if (file2.renameTo(file)) {
                        fileInputStream2 = null;
                    } else {
                        throw new IOException("Couldn't rename to " + file.getAbsolutePath());
                    }
                } else if (Build.VERSION.SDK_INT < 21 || this.f146815b == null) {
                    file = null;
                    fileInputStream2 = null;
                } else {
                    file = File.createTempFile("temp", "tmp");
                    Os.lseek(this.f146815b, 0, OsConstants.SEEK_SET);
                    fileInputStream2 = new FileInputStream(this.f146815b);
                    try {
                        fileOutputStream2 = new FileOutputStream(file);
                    } catch (Exception e12) {
                        e10 = e12;
                        closeable3 = null;
                        inputStream = fileInputStream2;
                        closeable2 = closeable3;
                        try {
                            throw new IOException("Failed to copy original file to temp file", e10);
                        } catch (Throwable th4) {
                            th2 = th4;
                            closeable = closeable2;
                            d(inputStream);
                            d(closeable);
                            throw th2;
                        }
                    } catch (Throwable th5) {
                        th2 = th5;
                        closeable4 = null;
                        inputStream = fileInputStream2;
                        closeable = closeable4;
                        d(inputStream);
                        d(closeable);
                        throw th2;
                    }
                    try {
                        h(fileInputStream2, fileOutputStream2);
                        fileInputStream = fileOutputStream2;
                        d(fileInputStream2);
                        d(fileInputStream);
                        FileInputStream fileInputStream3 = new FileInputStream(file);
                        if (this.f146814a == null) {
                            fileOutputStream = new FileOutputStream(this.f146814a);
                        } else if (Build.VERSION.SDK_INT < 21 || (fileDescriptor = this.f146815b) == null) {
                            fileOutputStream = null;
                        } else {
                            Os.lseek(fileDescriptor, 0, OsConstants.SEEK_SET);
                            fileOutputStream = new FileOutputStream(this.f146815b);
                        }
                        bufferedInputStream = new BufferedInputStream(fileInputStream3);
                        bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
                        i10 = this.f146817d;
                        if (i10 != 4) {
                            w0(bufferedInputStream, bufferedOutputStream);
                        } else if (i10 == 13) {
                            x0(bufferedInputStream, bufferedOutputStream);
                        } else if (i10 == 14) {
                            y0(bufferedInputStream, bufferedOutputStream);
                        }
                        d(bufferedInputStream);
                        d(bufferedOutputStream);
                        file.delete();
                        this.f146827n = null;
                    } catch (Exception e13) {
                        e10 = e13;
                        closeable3 = fileOutputStream2;
                    } catch (Throwable th6) {
                        th2 = th6;
                        closeable4 = fileOutputStream2;
                        inputStream = fileInputStream2;
                        closeable = closeable4;
                        d(inputStream);
                        d(closeable);
                        throw th2;
                    }
                }
                fileInputStream = fileInputStream2;
                d(fileInputStream2);
                d(fileInputStream);
                try {
                    FileInputStream fileInputStream32 = new FileInputStream(file);
                    if (this.f146814a == null) {
                    }
                    bufferedInputStream = new BufferedInputStream(fileInputStream32);
                    try {
                        bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
                    } catch (Exception e14) {
                        e11 = e14;
                        bufferedOutputStream = null;
                        inputStream = bufferedInputStream;
                        try {
                            if (this.f146814a != null) {
                            }
                            throw new IOException("Failed to save new file", e11);
                        } catch (Throwable th7) {
                            th3 = th7;
                            inputStream = inputStream;
                            d(inputStream);
                            d(bufferedOutputStream);
                            file.delete();
                            throw th3;
                        }
                    } catch (Throwable th8) {
                        th3 = th8;
                        bufferedOutputStream = null;
                        inputStream = bufferedInputStream;
                        d(inputStream);
                        d(bufferedOutputStream);
                        file.delete();
                        throw th3;
                    }
                    try {
                        i10 = this.f146817d;
                        if (i10 != 4) {
                        }
                        d(bufferedInputStream);
                        d(bufferedOutputStream);
                        file.delete();
                        this.f146827n = null;
                    } catch (Exception e15) {
                        e11 = e15;
                        inputStream = bufferedInputStream;
                        if (this.f146814a != null) {
                        }
                        throw new IOException("Failed to save new file", e11);
                    } catch (Throwable th9) {
                        th3 = th9;
                        inputStream = bufferedInputStream;
                        d(inputStream);
                        d(bufferedOutputStream);
                        file.delete();
                        throw th3;
                    }
                } catch (Exception e16) {
                    e11 = e16;
                    bufferedOutputStream = null;
                    if (this.f146814a != null || file.renameTo(file2)) {
                        throw new IOException("Failed to save new file", e11);
                    }
                    throw new IOException("Couldn't restore original file: " + file2.getAbsolutePath());
                } catch (Throwable th10) {
                    th3 = th10;
                    bufferedOutputStream = null;
                    d(inputStream);
                    d(bufferedOutputStream);
                    file.delete();
                    throw th3;
                }
            } catch (Exception e17) {
                e10 = e17;
                closeable2 = null;
                throw new IOException("Failed to copy original file to temp file", e10);
            } catch (Throwable th11) {
                th2 = th11;
                closeable = null;
                d(inputStream);
                d(closeable);
                throw th2;
            }
        }
    }

    @o0
    public final d w(@m0 String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        if (A0.equals(str)) {
            if (f146796y) {
                Log.d(f146787x, "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str = B0;
        }
        for (int i10 = 0; i10 < f146650f7.length; i10++) {
            d dVar = this.f146819f[i10].get(str);
            if (dVar != null) {
                return dVar;
            }
        }
        return null;
    }

    public final void w0(InputStream inputStream, OutputStream outputStream) throws IOException {
        if (f146796y) {
            Log.d(f146787x, "saveJpegAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        DataInputStream dataInputStream = new DataInputStream(inputStream);
        c cVar = new c(outputStream, ByteOrder.BIG_ENDIAN);
        if (dataInputStream.readByte() == -1) {
            cVar.b(-1);
            if (dataInputStream.readByte() == -40) {
                cVar.b(-40);
                d dVar = null;
                if (o(f146773v2) != null && this.f146836w) {
                    dVar = this.f146819f[0].remove(f146773v2);
                }
                cVar.b(-1);
                cVar.b(-31);
                J0(cVar);
                if (dVar != null) {
                    this.f146819f[0].put(f146773v2, dVar);
                }
                byte[] bArr = new byte[4096];
                while (dataInputStream.readByte() == -1) {
                    byte readByte = dataInputStream.readByte();
                    if (readByte == -39 || readByte == -38) {
                        cVar.b(-1);
                        cVar.b(readByte);
                        h(dataInputStream, cVar);
                        return;
                    } else if (readByte != -31) {
                        cVar.b(-1);
                        cVar.b(readByte);
                        int readUnsignedShort = dataInputStream.readUnsignedShort();
                        cVar.g(readUnsignedShort);
                        int i10 = readUnsignedShort - 2;
                        if (i10 >= 0) {
                            while (i10 > 0) {
                                int read = dataInputStream.read(bArr, 0, Math.min(i10, 4096));
                                if (read < 0) {
                                    break;
                                }
                                cVar.write(bArr, 0, read);
                                i10 -= read;
                            }
                        } else {
                            throw new IOException("Invalid length");
                        }
                    } else {
                        int readUnsignedShort2 = dataInputStream.readUnsignedShort() - 2;
                        if (readUnsignedShort2 >= 0) {
                            byte[] bArr2 = new byte[6];
                            if (readUnsignedShort2 >= 6) {
                                if (dataInputStream.read(bArr2) != 6) {
                                    throw new IOException("Invalid exif");
                                } else if (Arrays.equals(bArr2, f146722o7)) {
                                    int i11 = readUnsignedShort2 - 6;
                                    if (dataInputStream.skipBytes(i11) != i11) {
                                        throw new IOException("Invalid length");
                                    }
                                }
                            }
                            cVar.b(-1);
                            cVar.b(readByte);
                            cVar.g(readUnsignedShort2 + 2);
                            if (readUnsignedShort2 >= 6) {
                                readUnsignedShort2 -= 6;
                                cVar.write(bArr2);
                            }
                            while (readUnsignedShort2 > 0) {
                                int read2 = dataInputStream.read(bArr, 0, Math.min(readUnsignedShort2, 4096));
                                if (read2 < 0) {
                                    break;
                                }
                                cVar.write(bArr, 0, read2);
                                readUnsignedShort2 -= read2;
                            }
                        } else {
                            throw new IOException("Invalid length");
                        }
                    }
                }
                throw new IOException("Invalid marker");
            }
            throw new IOException("Invalid marker");
        }
        throw new IOException("Invalid marker");
    }

    @x0({x0.a.LIBRARY})
    public long x() {
        String o10 = o(f146621c2);
        String o11 = o(G1);
        if (!(o10 == null || o11 == null)) {
            Pattern pattern = Y7;
            if (pattern.matcher(o10).matches() || pattern.matcher(o11).matches()) {
                try {
                    Date parse = f146737q6.parse(o10 + ' ' + o11, new ParsePosition(0));
                    if (parse == null) {
                        return -1;
                    }
                    return parse.getTime();
                } catch (IllegalArgumentException unused) {
                }
            }
        }
        return -1;
    }

    public final void x0(InputStream inputStream, OutputStream outputStream) throws IOException {
        Throwable th2;
        if (f146796y) {
            Log.d(f146787x, "savePngAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        DataInputStream dataInputStream = new DataInputStream(inputStream);
        ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
        c cVar = new c(outputStream, byteOrder);
        byte[] bArr = V5;
        i(dataInputStream, cVar, bArr.length);
        int i10 = this.f146829p;
        if (i10 == 0) {
            int readInt = dataInputStream.readInt();
            cVar.c(readInt);
            i(dataInputStream, cVar, readInt + 4 + 4);
        } else {
            i(dataInputStream, cVar, ((i10 - bArr.length) - 4) - 4);
            dataInputStream.skipBytes(dataInputStream.readInt() + 4 + 4);
        }
        ByteArrayOutputStream byteArrayOutputStream = null;
        try {
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
            try {
                c cVar2 = new c(byteArrayOutputStream2, byteOrder);
                J0(cVar2);
                byte[] byteArray = ((ByteArrayOutputStream) cVar2.f146846a).toByteArray();
                cVar.write(byteArray);
                CRC32 crc32 = new CRC32();
                crc32.update(byteArray, 4, byteArray.length - 4);
                cVar.c((int) crc32.getValue());
                d(byteArrayOutputStream2);
                h(dataInputStream, cVar);
            } catch (Throwable th3) {
                th2 = th3;
                byteArrayOutputStream = byteArrayOutputStream2;
                d(byteArrayOutputStream);
                throw th2;
            }
        } catch (Throwable th4) {
            th2 = th4;
            d(byteArrayOutputStream);
            throw th2;
        }
    }

    public final void y(b bVar) throws IOException {
        String str;
        String str2;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new C1238a(bVar));
            } else {
                FileDescriptor fileDescriptor = this.f146815b;
                if (fileDescriptor != null) {
                    mediaMetadataRetriever.setDataSource(fileDescriptor);
                } else {
                    String str3 = this.f146814a;
                    if (str3 != null) {
                        mediaMetadataRetriever.setDataSource(str3);
                    } else {
                        mediaMetadataRetriever.release();
                        return;
                    }
                }
            }
            String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
            String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
            String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
            String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
            String str4 = null;
            if ("yes".equals(extractMetadata3)) {
                str4 = mediaMetadataRetriever.extractMetadata(29);
                str2 = mediaMetadataRetriever.extractMetadata(30);
                str = mediaMetadataRetriever.extractMetadata(31);
            } else if ("yes".equals(extractMetadata4)) {
                str4 = mediaMetadataRetriever.extractMetadata(18);
                str2 = mediaMetadataRetriever.extractMetadata(19);
                str = mediaMetadataRetriever.extractMetadata(24);
            } else {
                str2 = null;
                str = null;
            }
            if (str4 != null) {
                this.f146819f[0].put(f146805z, d.m(Integer.parseInt(str4), this.f146821h));
            }
            if (str2 != null) {
                this.f146819f[0].put(A, d.m(Integer.parseInt(str2), this.f146821h));
            }
            if (str != null) {
                int i10 = 1;
                int parseInt = Integer.parseInt(str);
                if (parseInt == 90) {
                    i10 = 6;
                } else if (parseInt == 180) {
                    i10 = 3;
                } else if (parseInt == 270) {
                    i10 = 8;
                }
                this.f146819f[0].put(E, d.m(i10, this.f146821h));
            }
            if (!(extractMetadata == null || extractMetadata2 == null)) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 > 6) {
                    bVar.d((long) parseInt2);
                    byte[] bArr = new byte[6];
                    if (bVar.read(bArr) == 6) {
                        int i11 = parseInt2 + 6;
                        int i12 = parseInt3 - 6;
                        if (Arrays.equals(bArr, f146722o7)) {
                            byte[] bArr2 = new byte[i12];
                            if (bVar.read(bArr2) == i12) {
                                this.f146829p = i11;
                                p0(bArr2, 0);
                            } else {
                                throw new IOException("Can't read exif");
                            }
                        } else {
                            throw new IOException("Invalid identifier");
                        }
                    } else {
                        throw new IOException("Can't read identifier");
                    }
                } else {
                    throw new IOException("Invalid exif length");
                }
            }
            if (f146796y) {
                Log.d(f146787x, "Heif meta: " + str4 + "x" + str2 + ", rotation " + str);
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void y0(InputStream inputStream, OutputStream outputStream) throws IOException {
        Throwable th2;
        Exception e10;
        if (f146796y) {
            Log.d(f146787x, "saveWebpAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")");
        }
        ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
        b bVar = new b(inputStream, byteOrder);
        c cVar = new c(outputStream, byteOrder);
        byte[] bArr = f146617b6;
        i(bVar, cVar, bArr.length);
        byte[] bArr2 = f146625c6;
        bVar.skipBytes(bArr2.length + 4);
        ByteArrayOutputStream byteArrayOutputStream = null;
        try {
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
            try {
                c cVar2 = new c(byteArrayOutputStream2, byteOrder);
                int i10 = this.f146829p;
                if (i10 != 0) {
                    i(bVar, cVar2, ((i10 - ((bArr.length + 4) + bArr2.length)) - 4) - 4);
                    bVar.skipBytes(4);
                    bVar.skipBytes(bVar.readInt());
                    J0(cVar2);
                } else {
                    byte[] bArr3 = new byte[4];
                    if (bVar.read(bArr3) == 4) {
                        byte[] bArr4 = f146665h6;
                        if (Arrays.equals(bArr3, bArr4)) {
                            int readInt = bVar.readInt();
                            boolean z10 = true;
                            byte[] bArr5 = new byte[(readInt % 2 == 1 ? readInt + 1 : readInt)];
                            bVar.read(bArr5);
                            bArr5[0] = (byte) (bArr5[0] | 8);
                            if (((bArr5[0] >> 1) & 1) != 1) {
                                z10 = false;
                            }
                            cVar2.write(bArr4);
                            cVar2.c(readInt);
                            cVar2.write(bArr5);
                            if (z10) {
                                j(bVar, cVar2, f146689k6, null);
                                while (true) {
                                    byte[] bArr6 = new byte[4];
                                    inputStream.read(bArr6);
                                    if (!Arrays.equals(bArr6, f146697l6)) {
                                        break;
                                    }
                                    k(bVar, cVar2, bArr6);
                                }
                                J0(cVar2);
                            } else {
                                j(bVar, cVar2, f146681j6, f146673i6);
                                J0(cVar2);
                            }
                        } else if (Arrays.equals(bArr3, f146681j6) || Arrays.equals(bArr3, f146673i6)) {
                            throw new IOException("WebP files with only VP8 or VP8L chunks are currently not supported");
                        }
                    } else {
                        throw new IOException("Encountered invalid length while parsing WebP chunk type");
                    }
                }
                h(bVar, cVar2);
                int size = byteArrayOutputStream2.size();
                byte[] bArr7 = f146625c6;
                cVar.c(size + bArr7.length);
                cVar.write(bArr7);
                byteArrayOutputStream2.writeTo(cVar);
                d(byteArrayOutputStream2);
            } catch (Exception e11) {
                e10 = e11;
                byteArrayOutputStream = byteArrayOutputStream2;
                try {
                    throw new IOException("Failed to save WebP file", e10);
                } catch (Throwable th3) {
                    th2 = th3;
                    d(byteArrayOutputStream);
                    throw th2;
                }
            } catch (Throwable th4) {
                th2 = th4;
                byteArrayOutputStream = byteArrayOutputStream2;
                d(byteArrayOutputStream);
                throw th2;
            }
        } catch (Exception e12) {
            e10 = e12;
            throw new IOException("Failed to save WebP file", e10);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:31:0x00c2 A[FALL_THROUGH] */
    public final void z(b bVar, int i10, int i11) throws IOException {
        int i12;
        int i13;
        if (f146796y) {
            Log.d(f146787x, "getJpegAttributes starting with: " + bVar);
        }
        bVar.f(ByteOrder.BIG_ENDIAN);
        bVar.d((long) i10);
        byte readByte = bVar.readByte();
        byte b10 = -1;
        if (readByte == -1) {
            int i14 = 1;
            int i15 = i10 + 1;
            if (bVar.readByte() == -40) {
                int i16 = i15 + 1;
                while (true) {
                    byte readByte2 = bVar.readByte();
                    if (readByte2 == b10) {
                        int i17 = i16 + i14;
                        byte readByte3 = bVar.readByte();
                        boolean z10 = f146796y;
                        if (z10) {
                            Log.d(f146787x, "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                        }
                        int i18 = i17 + i14;
                        if (readByte3 == -39 || readByte3 == -38) {
                            bVar.f(this.f146821h);
                        } else {
                            int readUnsignedShort = bVar.readUnsignedShort() - 2;
                            int i19 = i18 + 2;
                            if (z10) {
                                Log.d(f146787x, "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")");
                            }
                            if (readUnsignedShort >= 0) {
                                if (readByte3 == -31) {
                                    byte[] bArr = new byte[readUnsignedShort];
                                    bVar.readFully(bArr);
                                    i12 = i19 + readUnsignedShort;
                                    byte[] bArr2 = f146722o7;
                                    if (F0(bArr, bArr2)) {
                                        byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                                        this.f146829p = i19 + bArr2.length;
                                        p0(copyOfRange, i11);
                                    } else {
                                        byte[] bArr3 = f146730p7;
                                        if (F0(bArr, bArr3)) {
                                            int length = i19 + bArr3.length;
                                            byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                                            if (o(f146773v2) == null) {
                                                this.f146819f[0].put(f146773v2, new d(1, copyOfRange2.length, (long) length, copyOfRange2));
                                                i13 = 1;
                                                this.f146836w = true;
                                                readUnsignedShort = 0;
                                            }
                                        }
                                    }
                                    i13 = i14;
                                    readUnsignedShort = 0;
                                } else if (readByte3 != -2) {
                                    switch (readByte3) {
                                        default:
                                            switch (readByte3) {
                                                default:
                                                    switch (readByte3) {
                                                        default:
                                                            switch (readByte3) {
                                                            }
                                                        case -55:
                                                        case -54:
                                                        case -53:
                                                            if (bVar.skipBytes(i14) == i14) {
                                                                this.f146819f[i11].put(A, d.i((long) bVar.readUnsignedShort(), this.f146821h));
                                                                this.f146819f[i11].put(f146805z, d.i((long) bVar.readUnsignedShort(), this.f146821h));
                                                                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;
                                    }
                                    i12 = i19;
                                    i13 = i14;
                                } else {
                                    byte[] bArr4 = new byte[readUnsignedShort];
                                    if (bVar.read(bArr4) == readUnsignedShort) {
                                        if (o(f146699m0) == null) {
                                            this.f146819f[i14].put(f146699m0, d.h(new String(bArr4, f146714n7)));
                                        }
                                        i12 = i19;
                                        i13 = i14;
                                        readUnsignedShort = 0;
                                    } else {
                                        throw new IOException("Invalid exif");
                                    }
                                }
                                if (readUnsignedShort < 0) {
                                    throw new IOException("Invalid length");
                                } else if (bVar.skipBytes(readUnsignedShort) == readUnsignedShort) {
                                    i14 = i13;
                                    i16 = i12 + readUnsignedShort;
                                    b10 = -1;
                                } else {
                                    throw new IOException("Invalid JPEG segment");
                                }
                            } else {
                                throw new IOException("Invalid length");
                            }
                        }
                    } else {
                        throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
                    }
                }
                bVar.f(this.f146821h);
                return;
            }
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
        throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
    }

    public void z0(double d10) {
        String str = d10 >= 0.0d ? "0" : "1";
        A0(F1, new h(Math.abs(d10)).toString());
        A0(E1, str);
    }

    /* compiled from: ExifInterface */
    public static class f {

        /* renamed from: a  reason: collision with root package name */
        public final int f146853a;

        /* renamed from: b  reason: collision with root package name */
        public final String f146854b;

        /* renamed from: c  reason: collision with root package name */
        public final int f146855c;

        /* renamed from: d  reason: collision with root package name */
        public final int f146856d;

        public f(String str, int i10, int i11) {
            this.f146854b = str;
            this.f146853a = i10;
            this.f146855c = i11;
            this.f146856d = -1;
        }

        public boolean a(int i10) {
            int i11;
            int i12 = this.f146855c;
            if (i12 == 7 || i10 == 7 || i12 == i10 || (i11 = this.f146856d) == i10) {
                return true;
            }
            if ((i12 == 4 || i11 == 4) && i10 == 3) {
                return true;
            }
            if ((i12 == 9 || i11 == 9) && i10 == 8) {
                return true;
            }
            if ((i12 == 12 || i11 == 12) && i10 == 11) {
                return true;
            }
            return false;
        }

        public f(String str, int i10, int i11, int i12) {
            this.f146854b = str;
            this.f146853a = i10;
            this.f146855c = i11;
            this.f146856d = i12;
        }
    }

    public a(@m0 String str) throws IOException {
        f[][] fVarArr = f146650f7;
        this.f146819f = new HashMap[fVarArr.length];
        this.f146820g = new HashSet(fVarArr.length);
        this.f146821h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(str, "filename cannot be null");
        U(str);
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x005c  */
    public a(@m0 FileDescriptor fileDescriptor) throws IOException {
        FileInputStream fileInputStream;
        Throwable th2;
        f[][] fVarArr = f146650f7;
        this.f146819f = new HashMap[fVarArr.length];
        this.f146820g = new HashSet(fVarArr.length);
        this.f146821h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(fileDescriptor, "fileDescriptor cannot be null");
        this.f146816c = null;
        this.f146814a = null;
        boolean z10 = false;
        if (Build.VERSION.SDK_INT < 21 || !d0(fileDescriptor)) {
            this.f146815b = null;
        } else {
            this.f146815b = fileDescriptor;
            try {
                fileDescriptor = Os.dup(fileDescriptor);
                z10 = true;
            } catch (Exception e10) {
                throw new IOException("Failed to duplicate file descriptor", e10);
            }
        }
        try {
            fileInputStream = new FileInputStream(fileDescriptor);
            try {
                k0(fileInputStream);
                d(fileInputStream);
                if (z10) {
                    c(fileDescriptor);
                }
            } catch (Throwable th3) {
                th2 = th3;
                d(fileInputStream);
                if (z10) {
                    c(fileDescriptor);
                }
                throw th2;
            }
        } catch (Throwable th4) {
            fileInputStream = null;
            th2 = th4;
            d(fileInputStream);
            if (z10) {
            }
            throw th2;
        }
    }

    public a(@m0 InputStream inputStream) throws IOException {
        this(inputStream, false);
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public a(@m0 InputStream inputStream, int i10) throws IOException {
        this(inputStream, i10 != 1 ? false : true);
    }

    public a(@m0 InputStream inputStream, boolean z10) throws IOException {
        f[][] fVarArr = f146650f7;
        this.f146819f = new HashMap[fVarArr.length];
        this.f146820g = new HashSet(fVarArr.length);
        this.f146821h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(inputStream, "inputStream cannot be null");
        this.f146814a = null;
        if (z10) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            if (!V(bufferedInputStream)) {
                Log.w(f146787x, "Given data does not follow the structure of an Exif-only data.");
                return;
            }
            this.f146818e = true;
            this.f146816c = null;
            this.f146815b = null;
            inputStream = bufferedInputStream;
        } else if (inputStream instanceof AssetManager.AssetInputStream) {
            this.f146816c = (AssetManager.AssetInputStream) inputStream;
            this.f146815b = null;
        } else {
            if (inputStream instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) inputStream;
                if (d0(fileInputStream.getFD())) {
                    this.f146816c = null;
                    this.f146815b = fileInputStream.getFD();
                }
            }
            this.f146816c = null;
            this.f146815b = null;
        }
        k0(inputStream);
    }
}