Pdf Converter v5.0版本的 MD5 值为:258149214e8277c73fa6b365aba312ef

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


package s1;

import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
import androidx.activity.o;
import androidx.appcompat.widget.ActivityChooserView;
import androidx.camera.core.impl.b2;
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.FileDescriptor;
import java.io.FileInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
import md.v;
import okhttp3.HttpUrl;
import okhttp3.internal.ws.WebSocketProtocol;
import s1.c;
public final class b {
    public static final e U;
    public static final e[][] V;
    public static final e[] W;
    public static final HashMap<Integer, e>[] X;
    public static final HashMap<String, e>[] Y;
    public static final HashSet<String> Z;
    public static final HashMap<Integer, Integer> f24995a0;
    public static final Charset f24996b0;
    public static final byte[] f24997c0;
    public static final byte[] f24998d0;
    public static final Pattern f24999e0;
    public static final Pattern f25000f0;
    public static final Pattern f25001g0;
    public String f25009a;
    public FileDescriptor f25010b;
    public AssetManager.AssetInputStream f25011c;
    public int f25012d;
    public final HashMap<String, d>[] f25013e;
    public final HashSet f25014f;
    public ByteOrder f25015g;
    public boolean f25016h;
    public boolean f25017i;
    public boolean f25018j;
    public int f25019k;
    public int f25020l;
    public byte[] f25021m;
    public int f25022n;
    public int f25023o;
    public int f25024p;
    public int f25025q;
    public int f25026r;
    public boolean f25027s;
    public static final boolean f25002t = Log.isLoggable("ExifInterface", 3);
    public static final List<Integer> f25003u = Arrays.asList(1, 6, 3, 8);
    public static final List<Integer> f25004v = Arrays.asList(2, 7, 4, 5);
    public static final int[] f25005w = {8, 8, 8};
    public static final int[] f25006x = {8};
    public static final byte[] f25007y = {-1, -40, -1};
    public static final byte[] f25008z = {102, 116, 121, 112};
    public static final byte[] A = {109, 105, 102, 49};
    public static final byte[] B = {104, 101, 105, 99};
    public static final byte[] C = {79, 76, 89, 77, 80, 0};
    public static final byte[] D = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] E = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] F = {101, 88, 73, 102};
    public static final byte[] G = {73, 72, 68, 82};
    public static final byte[] H = {73, 69, 78, 68};
    public static final byte[] I = {82, 73, 70, 70};
    public static final byte[] J = {87, 69, 66, 80};
    public static final byte[] K = {69, 88, 73, 70};
    public static final byte[] L = {-99, 1, 42};
    public static final byte[] M = "VP8X".getBytes(Charset.defaultCharset());
    public static final byte[] N = "VP8L".getBytes(Charset.defaultCharset());
    public static final byte[] O = "VP8 ".getBytes(Charset.defaultCharset());
    public static final byte[] P = "ANIM".getBytes(Charset.defaultCharset());
    public static final byte[] Q = "ANMF".getBytes(Charset.defaultCharset());
    public static final String[] R = {HttpUrl.FRAGMENT_ENCODE_SET, "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    public static final int[] S = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    public static final byte[] T = {65, 83, 67, 73, 73, 0, 0, 0};

    public class a extends MediaDataSource {
        public long f25028r;
        public final g f25029s;

        public a(g gVar) {
            this.f25029s = gVar;
        }

        @Override
        public final void close() {
        }

        @Override
        public final long getSize() {
            return -1L;
        }

        @Override
        public final int readAt(long j10, byte[] bArr, int i10, int i11) {
            if (i11 == 0) {
                return 0;
            }
            if (j10 < 0) {
                return -1;
            }
            try {
                long j11 = this.f25028r;
                if (j11 != j10) {
                    if (j11 >= 0 && j10 >= j11 + this.f25029s.available()) {
                        return -1;
                    }
                    this.f25029s.b(j10);
                    this.f25028r = j10;
                }
                if (i11 > this.f25029s.available()) {
                    i11 = this.f25029s.available();
                }
                int read = this.f25029s.read(bArr, i10, i11);
                if (read >= 0) {
                    this.f25028r += read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.f25028r = -1L;
            return -1;
        }
    }

    public static class C0199b extends InputStream implements DataInput {
        public static final ByteOrder f25030v = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder f25031w = ByteOrder.BIG_ENDIAN;
        public final DataInputStream f25032r;
        public ByteOrder f25033s;
        public int f25034t;
        public byte[] f25035u;

        public C0199b(InputStream inputStream) {
            this(inputStream, ByteOrder.BIG_ENDIAN);
        }

        public C0199b(InputStream inputStream, ByteOrder byteOrder) {
            this.f25033s = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f25032r = dataInputStream;
            dataInputStream.mark(0);
            this.f25034t = 0;
            this.f25033s = byteOrder;
        }

        public C0199b(byte[] bArr) {
            this(new ByteArrayInputStream(bArr), ByteOrder.BIG_ENDIAN);
        }

        public final void a(int i10) {
            int i11 = 0;
            while (i11 < i10) {
                DataInputStream dataInputStream = this.f25032r;
                int i12 = i10 - i11;
                int skip = (int) dataInputStream.skip(i12);
                if (skip <= 0) {
                    if (this.f25035u == null) {
                        this.f25035u = new byte[8192];
                    }
                    skip = dataInputStream.read(this.f25035u, 0, Math.min(8192, i12));
                    if (skip == -1) {
                        throw new EOFException(v.b("Reached EOF while skipping ", i10, " bytes."));
                    }
                }
                i11 += skip;
            }
            this.f25034t += i11;
        }

        @Override
        public final int available() {
            return this.f25032r.available();
        }

        @Override
        public final void mark(int i10) {
            throw new UnsupportedOperationException("Mark is currently unsupported");
        }

        @Override
        public final int read() {
            this.f25034t++;
            return this.f25032r.read();
        }

        @Override
        public final int read(byte[] bArr, int i10, int i11) {
            int read = this.f25032r.read(bArr, i10, i11);
            this.f25034t += read;
            return read;
        }

        @Override
        public final boolean readBoolean() {
            this.f25034t++;
            return this.f25032r.readBoolean();
        }

        @Override
        public final byte readByte() {
            this.f25034t++;
            int read = this.f25032r.read();
            if (read >= 0) {
                return (byte) read;
            }
            throw new EOFException();
        }

        @Override
        public final char readChar() {
            this.f25034t += 2;
            return this.f25032r.readChar();
        }

        @Override
        public final double readDouble() {
            return Double.longBitsToDouble(readLong());
        }

        @Override
        public final float readFloat() {
            return Float.intBitsToFloat(readInt());
        }

        @Override
        public final void readFully(byte[] bArr) {
            this.f25034t += bArr.length;
            this.f25032r.readFully(bArr);
        }

        @Override
        public final void readFully(byte[] bArr, int i10, int i11) {
            this.f25034t += i11;
            this.f25032r.readFully(bArr, i10, i11);
        }

        @Override
        public final int readInt() {
            this.f25034t += 4;
            DataInputStream dataInputStream = this.f25032r;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            int read3 = dataInputStream.read();
            int read4 = dataInputStream.read();
            if ((read | read2 | read3 | read4) >= 0) {
                ByteOrder byteOrder = this.f25033s;
                if (byteOrder == f25030v) {
                    return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                }
                if (byteOrder == f25031w) {
                    return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                }
                throw new IOException("Invalid byte order: " + this.f25033s);
            }
            throw new EOFException();
        }

        @Override
        public final String readLine() {
            Log.d("ExifInterface", "Currently unsupported");
            return null;
        }

        @Override
        public final long readLong() {
            this.f25034t += 8;
            DataInputStream dataInputStream = this.f25032r;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            int read3 = dataInputStream.read();
            int read4 = dataInputStream.read();
            int read5 = dataInputStream.read();
            int read6 = dataInputStream.read();
            int read7 = dataInputStream.read();
            int read8 = dataInputStream.read();
            if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                ByteOrder byteOrder = this.f25033s;
                if (byteOrder == f25030v) {
                    return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                }
                if (byteOrder == f25031w) {
                    return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                }
                throw new IOException("Invalid byte order: " + this.f25033s);
            }
            throw new EOFException();
        }

        @Override
        public final short readShort() {
            this.f25034t += 2;
            DataInputStream dataInputStream = this.f25032r;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) >= 0) {
                ByteOrder byteOrder = this.f25033s;
                if (byteOrder == f25030v) {
                    return (short) ((read2 << 8) + read);
                }
                if (byteOrder == f25031w) {
                    return (short) ((read << 8) + read2);
                }
                throw new IOException("Invalid byte order: " + this.f25033s);
            }
            throw new EOFException();
        }

        @Override
        public final String readUTF() {
            this.f25034t += 2;
            return this.f25032r.readUTF();
        }

        @Override
        public final int readUnsignedByte() {
            this.f25034t++;
            return this.f25032r.readUnsignedByte();
        }

        @Override
        public final int readUnsignedShort() {
            this.f25034t += 2;
            DataInputStream dataInputStream = this.f25032r;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) >= 0) {
                ByteOrder byteOrder = this.f25033s;
                if (byteOrder == f25030v) {
                    return (read2 << 8) + read;
                }
                if (byteOrder == f25031w) {
                    return (read << 8) + read2;
                }
                throw new IOException("Invalid byte order: " + this.f25033s);
            }
            throw new EOFException();
        }

        @Override
        public final void reset() {
            throw new UnsupportedOperationException("Reset is currently unsupported");
        }

        @Override
        public final int skipBytes(int i10) {
            throw new UnsupportedOperationException("skipBytes is currently unsupported");
        }
    }

    public static class c extends FilterOutputStream {
        public final OutputStream f25036r;
        public ByteOrder f25037s;

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

        public final void a(int i10) {
            this.f25036r.write(i10);
        }

        public final void b(int i10) {
            ByteOrder byteOrder = this.f25037s;
            ByteOrder byteOrder2 = ByteOrder.LITTLE_ENDIAN;
            OutputStream outputStream = this.f25036r;
            if (byteOrder == byteOrder2) {
                outputStream.write((i10 >>> 0) & 255);
                outputStream.write((i10 >>> 8) & 255);
                outputStream.write((i10 >>> 16) & 255);
                outputStream.write((i10 >>> 24) & 255);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                outputStream.write((i10 >>> 24) & 255);
                outputStream.write((i10 >>> 16) & 255);
                outputStream.write((i10 >>> 8) & 255);
                outputStream.write((i10 >>> 0) & 255);
            }
        }

        public final void k(short s4) {
            ByteOrder byteOrder = this.f25037s;
            ByteOrder byteOrder2 = ByteOrder.LITTLE_ENDIAN;
            OutputStream outputStream = this.f25036r;
            if (byteOrder == byteOrder2) {
                outputStream.write((s4 >>> 0) & 255);
                outputStream.write((s4 >>> 8) & 255);
            } else if (byteOrder == ByteOrder.BIG_ENDIAN) {
                outputStream.write((s4 >>> 8) & 255);
                outputStream.write((s4 >>> 0) & 255);
            }
        }

        @Override
        public final void write(byte[] bArr) {
            this.f25036r.write(bArr);
        }

        @Override
        public final void write(byte[] bArr, int i10, int i11) {
            this.f25036r.write(bArr, i10, i11);
        }
    }

    public static class d {
        public final int f25038a;
        public final int f25039b;
        public final long f25040c;
        public final byte[] f25041d;

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

        public d(long j10, byte[] bArr, int i10, int i11) {
            this.f25038a = i10;
            this.f25039b = i11;
            this.f25040c = j10;
            this.f25041d = bArr;
        }

        public static d a(String str) {
            byte[] bytes = str.concat("\u0000").getBytes(b.f24996b0);
            return new d(2, bytes, bytes.length);
        }

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

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

        public static d d(f[] fVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[b.S[5] * fVarArr.length]);
            wrap.order(byteOrder);
            for (f fVar : fVarArr) {
                wrap.putInt((int) fVar.f25046a);
                wrap.putInt((int) fVar.f25047b);
            }
            return new d(5, wrap.array(), fVarArr.length);
        }

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

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

        public final double g(ByteOrder byteOrder) {
            Serializable j10 = j(byteOrder);
            if (j10 != null) {
                if (j10 instanceof String) {
                    return Double.parseDouble((String) j10);
                }
                if (j10 instanceof long[]) {
                    long[] jArr = (long[]) j10;
                    if (jArr.length == 1) {
                        return jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j10 instanceof int[]) {
                    int[] iArr = (int[]) j10;
                    if (iArr.length == 1) {
                        return iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j10 instanceof double[]) {
                    double[] dArr = (double[]) j10;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (j10 instanceof f[]) {
                    f[] fVarArr = (f[]) j10;
                    if (fVarArr.length == 1) {
                        f fVar = fVarArr[0];
                        return fVar.f25046a / fVar.f25047b;
                    }
                    throw new NumberFormatException("There are more than one component");
                } else {
                    throw new NumberFormatException("Couldn't find a double value");
                }
            }
            throw new NumberFormatException("NULL can't be converted to a double value");
        }

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

        public final String i(ByteOrder byteOrder) {
            Serializable j10 = j(byteOrder);
            if (j10 == null) {
                return null;
            }
            if (j10 instanceof String) {
                return (String) j10;
            }
            StringBuilder sb2 = new StringBuilder();
            int i10 = 0;
            if (j10 instanceof long[]) {
                long[] jArr = (long[]) j10;
                while (i10 < jArr.length) {
                    sb2.append(jArr[i10]);
                    i10++;
                    if (i10 != jArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (j10 instanceof int[]) {
                int[] iArr = (int[]) j10;
                while (i10 < iArr.length) {
                    sb2.append(iArr[i10]);
                    i10++;
                    if (i10 != iArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (j10 instanceof double[]) {
                double[] dArr = (double[]) j10;
                while (i10 < dArr.length) {
                    sb2.append(dArr[i10]);
                    i10++;
                    if (i10 != dArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (j10 instanceof f[]) {
                f[] fVarArr = (f[]) j10;
                while (i10 < fVarArr.length) {
                    sb2.append(fVarArr[i10].f25046a);
                    sb2.append('/');
                    sb2.append(fVarArr[i10].f25047b);
                    i10++;
                    if (i10 != fVarArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else {
                return null;
            }
        }

        public final Serializable j(ByteOrder byteOrder) {
            C0199b c0199b;
            InputStream inputStream;
            byte b10;
            byte[] bArr;
            byte[] bArr2 = this.f25041d;
            InputStream inputStream2 = null;
            try {
                try {
                    c0199b = new C0199b(bArr2);
                    try {
                        c0199b.f25033s = byteOrder;
                        int i10 = this.f25038a;
                        int i11 = 0;
                        boolean z10 = true;
                        int i12 = this.f25039b;
                        switch (i10) {
                            case 1:
                            case 6:
                                if (bArr2.length != 1 || (b10 = bArr2[0]) < 0 || b10 > 1) {
                                    String str = new String(bArr2, b.f24996b0);
                                    try {
                                        c0199b.close();
                                    } catch (IOException e10) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                    }
                                    return str;
                                }
                                String str2 = new String(new char[]{(char) (b10 + 48)});
                                try {
                                    c0199b.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (i12 >= b.T.length) {
                                    int i13 = 0;
                                    while (true) {
                                        bArr = b.T;
                                        if (i13 < bArr.length) {
                                            if (bArr2[i13] != bArr[i13]) {
                                                z10 = false;
                                            } else {
                                                i13++;
                                            }
                                        }
                                    }
                                    if (z10) {
                                        i11 = bArr.length;
                                    }
                                }
                                StringBuilder sb2 = new StringBuilder();
                                while (i11 < i12) {
                                    byte b11 = bArr2[i11];
                                    if (b11 == 0) {
                                        String sb3 = sb2.toString();
                                        c0199b.close();
                                        return sb3;
                                    }
                                    if (b11 >= 32) {
                                        sb2.append((char) b11);
                                    } else {
                                        sb2.append('?');
                                    }
                                    i11++;
                                }
                                String sb32 = sb2.toString();
                                c0199b.close();
                                return sb32;
                            case 3:
                                ?? r15 = new int[i12];
                                while (i11 < i12) {
                                    r15[i11] = c0199b.readUnsignedShort();
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return r15;
                            case 4:
                                ?? r152 = new long[i12];
                                while (i11 < i12) {
                                    r152[i11] = c0199b.readInt() & 4294967295L;
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e13) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                                }
                                return r152;
                            case 5:
                                ?? r153 = new f[i12];
                                while (i11 < i12) {
                                    r153[i11] = new f(c0199b.readInt() & 4294967295L, c0199b.readInt() & 4294967295L);
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e14) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                                }
                                return r153;
                            case 8:
                                ?? r154 = new int[i12];
                                while (i11 < i12) {
                                    r154[i11] = c0199b.readShort();
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e15) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                                }
                                return r154;
                            case 9:
                                ?? r155 = new int[i12];
                                while (i11 < i12) {
                                    r155[i11] = c0199b.readInt();
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e16) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                                }
                                return r155;
                            case 10:
                                ?? r156 = new f[i12];
                                while (i11 < i12) {
                                    r156[i11] = new f(c0199b.readInt(), c0199b.readInt());
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e17) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e17);
                                }
                                return r156;
                            case 11:
                                ?? r157 = new double[i12];
                                while (i11 < i12) {
                                    r157[i11] = c0199b.readFloat();
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e18) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e18);
                                }
                                return r157;
                            case 12:
                                ?? r158 = new double[i12];
                                while (i11 < i12) {
                                    r158[i11] = c0199b.readDouble();
                                    i11++;
                                }
                                try {
                                    c0199b.close();
                                } catch (IOException e19) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e19);
                                }
                                return r158;
                            default:
                                try {
                                    c0199b.close();
                                } catch (IOException e20) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e20);
                                }
                                return null;
                        }
                    } catch (IOException e21) {
                        e = e21;
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (c0199b != null) {
                            try {
                                c0199b.close();
                            } catch (IOException e22) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e22);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th) {
                    th = th;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e23) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e23);
                        }
                    }
                    throw th;
                }
            } catch (IOException e24) {
                e = e24;
                c0199b = null;
            } catch (Throwable th2) {
                th = th2;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

        public final String toString() {
            StringBuilder sb2 = new StringBuilder("(");
            sb2.append(b.R[this.f25038a]);
            sb2.append(", data length:");
            return b2.d(sb2, this.f25041d.length, ")");
        }
    }

    public static class e {
        public final int f25042a;
        public final String f25043b;
        public final int f25044c;
        public final int f25045d;

        public e(int i10, String str, int i11, int i12) {
            this.f25043b = str;
            this.f25042a = i10;
            this.f25044c = i11;
            this.f25045d = i12;
        }

        public e(String str, int i10, int i11) {
            this.f25043b = str;
            this.f25042a = i10;
            this.f25044c = i11;
            this.f25045d = -1;
        }
    }

    public static class f {
        public final long f25046a;
        public final long f25047b;

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

        public f(long j10, long j11) {
            if (j11 == 0) {
                this.f25046a = 0L;
                this.f25047b = 1L;
                return;
            }
            this.f25046a = j10;
            this.f25047b = j11;
        }

        public final String toString() {
            return this.f25046a + "/" + this.f25047b;
        }
    }

    public static class g extends C0199b {
        public g(InputStream inputStream) {
            super(inputStream);
            if (!inputStream.markSupported()) {
                throw new IllegalArgumentException("Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset");
            }
            this.f25032r.mark(ActivityChooserView.ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        }

        public g(byte[] bArr) {
            super(bArr);
            this.f25032r.mark(ActivityChooserView.ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        }

        public final void b(long j10) {
            int i10 = this.f25034t;
            if (i10 > j10) {
                this.f25034t = 0;
                this.f25032r.reset();
            } else {
                j10 -= i10;
            }
            a((int) j10);
        }
    }

    static {
        e[] eVarArr;
        e[] eVarArr2 = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e(256, "ImageWidth", 3, 4), new e(257, "ImageLength", 3, 4), new e("BitsPerSample", 258, 3), new e("Compression", 259, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e(273, "StripOffsets", 3, 4), new e("Orientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e(278, "RowsPerStrip", 3, 4), new e(279, "StripByteCounts", 3, 4), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("SensorTopBorder", 4, 4), new e("SensorLeftBorder", 5, 4), new e("SensorBottomBorder", 6, 4), new e("SensorRightBorder", 7, 4), new e("ISO", 23, 3), new e("JpgFromRaw", 46, 7), new e("Xmp", 700, 1)};
        e[] eVarArr3 = {new e("ExposureTime", 33434, 5), new e("FNumber", 33437, 5), new e("ExposureProgram", 34850, 3), new e("SpectralSensitivity", 34852, 2), new e("PhotographicSensitivity", 34855, 3), new e("OECF", 34856, 7), new e("SensitivityType", 34864, 3), new e("StandardOutputSensitivity", 34865, 4), new e("RecommendedExposureIndex", 34866, 4), new e("ISOSpeed", 34867, 4), new e("ISOSpeedLatitudeyyy", 34868, 4), new e("ISOSpeedLatitudezzz", 34869, 4), new e("ExifVersion", 36864, 2), new e("DateTimeOriginal", 36867, 2), new e("DateTimeDigitized", 36868, 2), new e("OffsetTime", 36880, 2), new e("OffsetTimeOriginal", 36881, 2), new e("OffsetTimeDigitized", 36882, 2), new e("ComponentsConfiguration", 37121, 7), new e("CompressedBitsPerPixel", 37122, 5), new e("ShutterSpeedValue", 37377, 10), new e("ApertureValue", 37378, 5), new e("BrightnessValue", 37379, 10), new e("ExposureBiasValue", 37380, 10), new e("MaxApertureValue", 37381, 5), new e("SubjectDistance", 37382, 5), new e("MeteringMode", 37383, 3), new e("LightSource", 37384, 3), new e("Flash", 37385, 3), new e("FocalLength", 37386, 5), new e("SubjectArea", 37396, 3), new e("MakerNote", 37500, 7), new e("UserComment", 37510, 7), new e("SubSecTime", 37520, 2), new e("SubSecTimeOriginal", 37521, 2), new e("SubSecTimeDigitized", 37522, 2), new e("FlashpixVersion", 40960, 7), new e("ColorSpace", 40961, 3), new e(40962, "PixelXDimension", 3, 4), new e(40963, "PixelYDimension", 3, 4), new e("RelatedSoundFile", 40964, 2), new e("InteroperabilityIFDPointer", 40965, 4), new e("FlashEnergy", 41483, 5), new e("SpatialFrequencyResponse", 41484, 7), new e("FocalPlaneXResolution", 41486, 5), new e("FocalPlaneYResolution", 41487, 5), new e("FocalPlaneResolutionUnit", 41488, 3), new e("SubjectLocation", 41492, 3), new e("ExposureIndex", 41493, 5), new e("SensingMethod", 41495, 3), new e("FileSource", 41728, 7), new e("SceneType", 41729, 7), new e("CFAPattern", 41730, 7), new e("CustomRendered", 41985, 3), new e("ExposureMode", 41986, 3), new e("WhiteBalance", 41987, 3), new e("DigitalZoomRatio", 41988, 5), new e("FocalLengthIn35mmFilm", 41989, 3), new e("SceneCaptureType", 41990, 3), new e("GainControl", 41991, 3), new e("Contrast", 41992, 3), new e("Saturation", 41993, 3), new e("Sharpness", 41994, 3), new e("DeviceSettingDescription", 41995, 7), new e("SubjectDistanceRange", 41996, 3), new e("ImageUniqueID", 42016, 2), new e("CameraOwnerName", 42032, 2), new e("BodySerialNumber", 42033, 2), new e("LensSpecification", 42034, 5), new e("LensMake", 42035, 2), new e("LensModel", 42036, 2), new e("Gamma", 42240, 5), new e("DNGVersion", 50706, 1), new e(50720, "DefaultCropSize", 3, 4)};
        e[] eVarArr4 = {new e("GPSVersionID", 0, 1), new e("GPSLatitudeRef", 1, 2), new e(2, "GPSLatitude", 5, 10), new e("GPSLongitudeRef", 3, 2), new e(4, "GPSLongitude", 5, 10), new e("GPSAltitudeRef", 5, 1), new e("GPSAltitude", 6, 5), new e("GPSTimeStamp", 7, 5), new e("GPSSatellites", 8, 2), new e("GPSStatus", 9, 2), new e("GPSMeasureMode", 10, 2), new e("GPSDOP", 11, 5), new e("GPSSpeedRef", 12, 2), new e("GPSSpeed", 13, 5), new e("GPSTrackRef", 14, 2), new e("GPSTrack", 15, 5), new e("GPSImgDirectionRef", 16, 2), new e("GPSImgDirection", 17, 5), new e("GPSMapDatum", 18, 2), new e("GPSDestLatitudeRef", 19, 2), new e("GPSDestLatitude", 20, 5), new e("GPSDestLongitudeRef", 21, 2), new e("GPSDestLongitude", 22, 5), new e("GPSDestBearingRef", 23, 2), new e("GPSDestBearing", 24, 5), new e("GPSDestDistanceRef", 25, 2), new e("GPSDestDistance", 26, 5), new e("GPSProcessingMethod", 27, 7), new e("GPSAreaInformation", 28, 7), new e("GPSDateStamp", 29, 2), new e("GPSDifferential", 30, 3), new e("GPSHPositioningError", 31, 5)};
        e[] eVarArr5 = {new e("InteroperabilityIndex", 1, 2)};
        e[] eVarArr6 = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e(256, "ThumbnailImageWidth", 3, 4), new e(257, "ThumbnailImageLength", 3, 4), new e("BitsPerSample", 258, 3), new e("Compression", 259, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e(273, "StripOffsets", 3, 4), new e("ThumbnailOrientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e(278, "RowsPerStrip", 3, 4), new e(279, "StripByteCounts", 3, 4), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("DNGVersion", 50706, 1), new e(50720, "DefaultCropSize", 3, 4)};
        U = new e("StripOffsets", 273, 3);
        V = new e[][]{eVarArr2, eVarArr3, eVarArr4, eVarArr5, eVarArr6, eVarArr2, new e[]{new e("ThumbnailImage", 256, 7), new e("CameraSettingsIFDPointer", 8224, 4), new e("ImageProcessingIFDPointer", 8256, 4)}, new e[]{new e("PreviewImageStart", 257, 4), new e("PreviewImageLength", 258, 4)}, new e[]{new e("AspectFrame", 4371, 3)}, new e[]{new e("ColorSpace", 55, 3)}};
        W = new e[]{new e("SubIFDPointer", 330, 4), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("InteroperabilityIFDPointer", 40965, 4), new e("CameraSettingsIFDPointer", 8224, 1), new e("ImageProcessingIFDPointer", 8256, 1)};
        X = new HashMap[10];
        Y = new HashMap[10];
        Z = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        f24995a0 = new HashMap<>();
        Charset forName = Charset.forName("US-ASCII");
        f24996b0 = forName;
        f24997c0 = "Exif\u0000\u0000".getBytes(forName);
        f24998d0 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        Locale locale = Locale.US;
        new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).setTimeZone(TimeZone.getTimeZone("UTC"));
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale).setTimeZone(TimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            e[][] eVarArr7 = V;
            if (i10 >= eVarArr7.length) {
                HashMap<Integer, Integer> hashMap = f24995a0;
                e[] eVarArr8 = W;
                hashMap.put(Integer.valueOf(eVarArr8[0].f25042a), 5);
                hashMap.put(Integer.valueOf(eVarArr8[1].f25042a), 1);
                hashMap.put(Integer.valueOf(eVarArr8[2].f25042a), 2);
                hashMap.put(Integer.valueOf(eVarArr8[3].f25042a), 3);
                hashMap.put(Integer.valueOf(eVarArr8[4].f25042a), 7);
                hashMap.put(Integer.valueOf(eVarArr8[5].f25042a), 8);
                Pattern.compile(".*[1-9].*");
                f24999e0 = Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})$");
                f25000f0 = Pattern.compile("^(\\d{4}):(\\d{2}):(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                f25001g0 = Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                return;
            }
            X[i10] = new HashMap<>();
            Y[i10] = new HashMap<>();
            for (e eVar : eVarArr7[i10]) {
                X[i10].put(Integer.valueOf(eVar.f25042a), eVar);
                Y[i10].put(eVar.f25043b, eVar);
            }
            i10++;
        }
    }

    public b(InputStream inputStream) {
        boolean z10;
        e[][] eVarArr = V;
        this.f25013e = new HashMap[eVarArr.length];
        this.f25014f = new HashSet(eVarArr.length);
        this.f25015g = ByteOrder.BIG_ENDIAN;
        if (inputStream == null) {
            throw new NullPointerException("inputStream cannot be null");
        }
        this.f25009a = null;
        if (inputStream instanceof AssetManager.AssetInputStream) {
            this.f25011c = (AssetManager.AssetInputStream) inputStream;
            this.f25010b = null;
        } else {
            if (inputStream instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) inputStream;
                try {
                    c.a.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                    z10 = true;
                } catch (Exception unused) {
                    if (f25002t) {
                        Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                    }
                    z10 = false;
                }
                if (z10) {
                    this.f25011c = null;
                    this.f25010b = fileInputStream.getFD();
                }
            }
            this.f25011c = null;
            this.f25010b = null;
        }
        t(inputStream);
    }

    public b(String str) {
        FileInputStream fileInputStream;
        boolean z10;
        e[][] eVarArr = V;
        this.f25013e = new HashMap[eVarArr.length];
        this.f25014f = new HashSet(eVarArr.length);
        this.f25015g = ByteOrder.BIG_ENDIAN;
        if (str == null) {
            throw new NullPointerException("filename cannot be null");
        }
        FileInputStream fileInputStream2 = null;
        this.f25011c = null;
        this.f25009a = str;
        try {
            fileInputStream = new FileInputStream(str);
        } catch (Throwable th) {
            th = th;
        }
        try {
            try {
                c.a.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                z10 = true;
            } catch (Exception unused) {
                if (f25002t) {
                    Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                }
                z10 = false;
            }
            if (z10) {
                this.f25010b = fileInputStream.getFD();
            } else {
                this.f25010b = null;
            }
            t(fileInputStream);
            s1.c.b(fileInputStream);
        } catch (Throwable th2) {
            th = th2;
            fileInputStream2 = fileInputStream;
            s1.c.b(fileInputStream2);
            throw th;
        }
    }

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

    public static void c(C0199b c0199b, c cVar, byte[] bArr, byte[] bArr2) {
        while (true) {
            byte[] bArr3 = new byte[4];
            if (c0199b.read(bArr3) != 4) {
                StringBuilder sb2 = new StringBuilder("Encountered invalid length while copying WebP chunks up tochunk type ");
                Charset charset = f24996b0;
                sb2.append(new String(bArr, charset));
                sb2.append(bArr2 == null ? HttpUrl.FRAGMENT_ENCODE_SET : " or ".concat(new String(bArr2, charset)));
                throw new IOException(sb2.toString());
            }
            int readInt = c0199b.readInt();
            cVar.write(bArr3);
            cVar.b(readInt);
            if (readInt % 2 == 1) {
                readInt++;
            }
            s1.c.e(c0199b, cVar, readInt);
            if (Arrays.equals(bArr3, bArr)) {
                return;
            }
            if (bArr2 != null && Arrays.equals(bArr3, bArr2)) {
                return;
            }
        }
    }

    public static Pair<Integer, Integer> q(String str) {
        if (str.contains(",")) {
            String[] split = str.split(",", -1);
            Pair<Integer, Integer> q4 = q(split[0]);
            if (((Integer) q4.first).intValue() == 2) {
                return q4;
            }
            for (int i10 = 1; i10 < split.length; i10++) {
                Pair<Integer, Integer> q10 = q(split[i10]);
                int intValue = (((Integer) q10.first).equals(q4.first) || ((Integer) q10.second).equals(q4.first)) ? ((Integer) q4.first).intValue() : -1;
                int intValue2 = (((Integer) q4.second).intValue() == -1 || !(((Integer) q10.first).equals(q4.second) || ((Integer) q10.second).equals(q4.second))) ? -1 : ((Integer) q4.second).intValue();
                if (intValue == -1 && intValue2 == -1) {
                    return new Pair<>(2, -1);
                }
                if (intValue == -1) {
                    q4 = new Pair<>(Integer.valueOf(intValue2), -1);
                } else if (intValue2 == -1) {
                    q4 = new Pair<>(Integer.valueOf(intValue), -1);
                }
            }
            return q4;
        } else if (!str.contains("/")) {
            try {
                try {
                    Long valueOf = Long.valueOf(Long.parseLong(str));
                    return (valueOf.longValue() < 0 || valueOf.longValue() > WebSocketProtocol.PAYLOAD_SHORT_MAX) ? valueOf.longValue() < 0 ? new Pair<>(9, -1) : new Pair<>(4, -1) : new Pair<>(3, 4);
                } catch (NumberFormatException unused) {
                    return new Pair<>(2, -1);
                }
            } catch (NumberFormatException unused2) {
                Double.parseDouble(str);
                return new Pair<>(12, -1);
            }
        } else {
            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 && parseDouble2 >= 0) {
                        if (parseDouble <= 2147483647L && parseDouble2 <= 2147483647L) {
                            return new Pair<>(10, 5);
                        }
                        return new Pair<>(5, -1);
                    }
                    return new Pair<>(10, -1);
                } catch (NumberFormatException unused3) {
                }
            }
            return new Pair<>(2, -1);
        }
    }

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

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

    public final void B(BufferedInputStream bufferedInputStream, BufferedOutputStream bufferedOutputStream) {
        if (f25002t) {
            Log.d("ExifInterface", "saveJpegAttributes starting with (inputStream: " + bufferedInputStream + ", outputStream: " + bufferedOutputStream + ")");
        }
        C0199b c0199b = new C0199b(bufferedInputStream);
        c cVar = new c(bufferedOutputStream, ByteOrder.BIG_ENDIAN);
        if (c0199b.readByte() != -1) {
            throw new IOException("Invalid marker");
        }
        cVar.a(-1);
        if (c0199b.readByte() != -40) {
            throw new IOException("Invalid marker");
        }
        cVar.a(-40);
        String d10 = d("Xmp");
        HashMap<String, d>[] hashMapArr = this.f25013e;
        d remove = (d10 == null || !this.f25027s) ? null : hashMapArr[0].remove("Xmp");
        cVar.a(-1);
        cVar.a(-31);
        J(cVar);
        if (remove != null) {
            hashMapArr[0].put("Xmp", remove);
        }
        byte[] bArr = new byte[4096];
        while (c0199b.readByte() == -1) {
            byte readByte = c0199b.readByte();
            if (readByte == -39 || readByte == -38) {
                cVar.a(-1);
                cVar.a(readByte);
                s1.c.d(c0199b, cVar);
                return;
            } else if (readByte != -31) {
                cVar.a(-1);
                cVar.a(readByte);
                int readUnsignedShort = c0199b.readUnsignedShort();
                cVar.k((short) readUnsignedShort);
                int i10 = readUnsignedShort - 2;
                if (i10 < 0) {
                    throw new IOException("Invalid length");
                }
                while (i10 > 0) {
                    int read = c0199b.read(bArr, 0, Math.min(i10, 4096));
                    if (read >= 0) {
                        cVar.write(bArr, 0, read);
                        i10 -= read;
                    }
                }
            } else {
                int readUnsignedShort2 = c0199b.readUnsignedShort() - 2;
                if (readUnsignedShort2 < 0) {
                    throw new IOException("Invalid length");
                }
                byte[] bArr2 = new byte[6];
                if (readUnsignedShort2 >= 6) {
                    if (c0199b.read(bArr2) != 6) {
                        throw new IOException("Invalid exif");
                    }
                    if (Arrays.equals(bArr2, f24997c0)) {
                        c0199b.a(readUnsignedShort2 - 6);
                    }
                }
                cVar.a(-1);
                cVar.a(readByte);
                cVar.k((short) (readUnsignedShort2 + 2));
                if (readUnsignedShort2 >= 6) {
                    readUnsignedShort2 -= 6;
                    cVar.write(bArr2);
                }
                while (readUnsignedShort2 > 0) {
                    int read2 = c0199b.read(bArr, 0, Math.min(readUnsignedShort2, 4096));
                    if (read2 >= 0) {
                        cVar.write(bArr, 0, read2);
                        readUnsignedShort2 -= read2;
                    }
                }
            }
        }
        throw new IOException("Invalid marker");
    }

    public final void C(BufferedInputStream bufferedInputStream, BufferedOutputStream bufferedOutputStream) {
        ByteArrayOutputStream byteArrayOutputStream;
        if (f25002t) {
            Log.d("ExifInterface", "savePngAttributes starting with (inputStream: " + bufferedInputStream + ", outputStream: " + bufferedOutputStream + ")");
        }
        C0199b c0199b = new C0199b(bufferedInputStream);
        ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
        c cVar = new c(bufferedOutputStream, byteOrder);
        byte[] bArr = E;
        s1.c.e(c0199b, cVar, bArr.length);
        int i10 = this.f25023o;
        if (i10 == 0) {
            int readInt = c0199b.readInt();
            cVar.b(readInt);
            s1.c.e(c0199b, cVar, readInt + 4 + 4);
        } else {
            s1.c.e(c0199b, cVar, ((i10 - bArr.length) - 4) - 4);
            c0199b.a(c0199b.readInt() + 4 + 4);
        }
        try {
            byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                c cVar2 = new c(byteArrayOutputStream, byteOrder);
                J(cVar2);
                byte[] byteArray = ((ByteArrayOutputStream) cVar2.f25036r).toByteArray();
                cVar.write(byteArray);
                CRC32 crc32 = new CRC32();
                crc32.update(byteArray, 4, byteArray.length - 4);
                cVar.b((int) crc32.getValue());
                s1.c.b(byteArrayOutputStream);
                s1.c.d(c0199b, cVar);
            } catch (Throwable th) {
                th = th;
                s1.c.b(byteArrayOutputStream);
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
            byteArrayOutputStream = null;
        }
    }

    public final void D(BufferedInputStream bufferedInputStream, BufferedOutputStream bufferedOutputStream) {
        ByteArrayOutputStream byteArrayOutputStream;
        c cVar;
        int i10;
        int i11;
        int i12;
        int i13;
        int i14;
        byte[] bArr;
        if (f25002t) {
            Log.d("ExifInterface", "saveWebpAttributes starting with (inputStream: " + bufferedInputStream + ", outputStream: " + bufferedOutputStream + ")");
        }
        ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
        C0199b c0199b = new C0199b(bufferedInputStream, byteOrder);
        c cVar2 = new c(bufferedOutputStream, byteOrder);
        byte[] bArr2 = I;
        s1.c.e(c0199b, cVar2, bArr2.length);
        byte[] bArr3 = J;
        c0199b.a(bArr3.length + 4);
        ByteArrayOutputStream byteArrayOutputStream2 = null;
        try {
            try {
                byteArrayOutputStream = new ByteArrayOutputStream();
            } catch (Exception e10) {
                e = e10;
            }
        } catch (Throwable th) {
            th = th;
            byteArrayOutputStream = byteArrayOutputStream2;
        }
        try {
            c cVar3 = new c(byteArrayOutputStream, byteOrder);
            int i15 = this.f25023o;
            if (i15 != 0) {
                s1.c.e(c0199b, cVar3, ((i15 - ((bArr2.length + 4) + bArr3.length)) - 4) - 4);
                c0199b.a(4);
                c0199b.a(c0199b.readInt());
                J(cVar3);
            } else {
                byte[] bArr4 = new byte[4];
                if (c0199b.read(bArr4) != 4) {
                    throw new IOException("Encountered invalid length while parsing WebP chunk type");
                }
                byte[] bArr5 = M;
                boolean equals = Arrays.equals(bArr4, bArr5);
                byte[] bArr6 = O;
                byte[] bArr7 = N;
                if (!equals) {
                    if (!Arrays.equals(bArr4, bArr6)) {
                        if (Arrays.equals(bArr4, bArr7)) {
                        }
                    }
                    int readInt = c0199b.readInt();
                    int i16 = readInt % 2 == 1 ? readInt + 1 : readInt;
                    byte[] bArr8 = new byte[3];
                    boolean equals2 = Arrays.equals(bArr4, bArr6);
                    byte[] bArr9 = L;
                    if (equals2) {
                        c0199b.read(bArr8);
                        byte[] bArr10 = new byte[3];
                        cVar = cVar2;
                        if (c0199b.read(bArr10) != 3 || !Arrays.equals(bArr9, bArr10)) {
                            throw new IOException("Encountered error while checking VP8 signature");
                        }
                        i10 = c0199b.readInt();
                        i11 = (i10 << 18) >> 18;
                        i12 = (i10 << 2) >> 18;
                        i16 -= 10;
                    } else {
                        cVar = cVar2;
                        if (Arrays.equals(bArr4, bArr7)) {
                            if (c0199b.readByte() != 47) {
                                throw new IOException("Encountered error while checking VP8L signature");
                            }
                            i10 = c0199b.readInt();
                            i11 = ((i10 << 18) >> 18) + 1;
                            i13 = ((i10 << 4) >> 18) + 1;
                            i14 = i10 & 8;
                            i16 -= 5;
                            cVar3.write(bArr5);
                            cVar3.b(10);
                            byte[] bArr11 = new byte[10];
                            bArr = bArr3;
                            byte b10 = (byte) (bArr11[0] | 8);
                            bArr11[0] = b10;
                            bArr11[0] = (byte) (b10 | (i14 << 4));
                            int i17 = i11 - 1;
                            int i18 = i13 - 1;
                            bArr11[4] = (byte) i17;
                            bArr11[5] = (byte) (i17 >> 8);
                            bArr11[6] = (byte) (i17 >> 16);
                            bArr11[7] = (byte) i18;
                            bArr11[8] = (byte) (i18 >> 8);
                            bArr11[9] = (byte) (i18 >> 16);
                            cVar3.write(bArr11);
                            cVar3.write(bArr4);
                            cVar3.b(readInt);
                            if (!Arrays.equals(bArr4, bArr6)) {
                                cVar3.write(bArr8);
                                cVar3.write(bArr9);
                                cVar3.b(i10);
                            } else if (Arrays.equals(bArr4, bArr7)) {
                                cVar3.write(47);
                                cVar3.b(i10);
                            }
                            s1.c.e(c0199b, cVar3, i16);
                            J(cVar3);
                            s1.c.d(c0199b, cVar3);
                            byte[] bArr12 = bArr;
                            c cVar4 = cVar;
                            cVar4.b(byteArrayOutputStream.size() + bArr12.length);
                            cVar4.write(bArr12);
                            byteArrayOutputStream.writeTo(cVar4);
                            s1.c.b(byteArrayOutputStream);
                        }
                        i10 = 0;
                        i11 = 0;
                        i12 = 0;
                    }
                    i13 = i12;
                    i14 = 0;
                    cVar3.write(bArr5);
                    cVar3.b(10);
                    byte[] bArr112 = new byte[10];
                    bArr = bArr3;
                    byte b102 = (byte) (bArr112[0] | 8);
                    bArr112[0] = b102;
                    bArr112[0] = (byte) (b102 | (i14 << 4));
                    int i172 = i11 - 1;
                    int i182 = i13 - 1;
                    bArr112[4] = (byte) i172;
                    bArr112[5] = (byte) (i172 >> 8);
                    bArr112[6] = (byte) (i172 >> 16);
                    bArr112[7] = (byte) i182;
                    bArr112[8] = (byte) (i182 >> 8);
                    bArr112[9] = (byte) (i182 >> 16);
                    cVar3.write(bArr112);
                    cVar3.write(bArr4);
                    cVar3.b(readInt);
                    if (!Arrays.equals(bArr4, bArr6)) {
                    }
                    s1.c.e(c0199b, cVar3, i16);
                    J(cVar3);
                    s1.c.d(c0199b, cVar3);
                    byte[] bArr122 = bArr;
                    c cVar42 = cVar;
                    cVar42.b(byteArrayOutputStream.size() + bArr122.length);
                    cVar42.write(bArr122);
                    byteArrayOutputStream.writeTo(cVar42);
                    s1.c.b(byteArrayOutputStream);
                }
                int readInt2 = c0199b.readInt();
                byte[] bArr13 = new byte[readInt2 % 2 == 1 ? readInt2 + 1 : readInt2];
                c0199b.read(bArr13);
                byte b11 = (byte) (bArr13[0] | 8);
                bArr13[0] = b11;
                boolean z10 = ((b11 >> 1) & 1) == 1;
                cVar3.write(bArr5);
                cVar3.b(readInt2);
                cVar3.write(bArr13);
                if (z10) {
                    c(c0199b, cVar3, P, null);
                    while (true) {
                        byte[] bArr14 = new byte[4];
                        bufferedInputStream.read(bArr14);
                        if (!Arrays.equals(bArr14, Q)) {
                            break;
                        }
                        int readInt3 = c0199b.readInt();
                        cVar3.write(bArr14);
                        cVar3.b(readInt3);
                        if (readInt3 % 2 == 1) {
                            readInt3++;
                        }
                        s1.c.e(c0199b, cVar3, readInt3);
                    }
                    J(cVar3);
                } else {
                    c(c0199b, cVar3, bArr6, bArr7);
                    J(cVar3);
                }
            }
            cVar = cVar2;
            bArr = bArr3;
            s1.c.d(c0199b, cVar3);
            byte[] bArr1222 = bArr;
            c cVar422 = cVar;
            cVar422.b(byteArrayOutputStream.size() + bArr1222.length);
            cVar422.write(bArr1222);
            byteArrayOutputStream.writeTo(cVar422);
            s1.c.b(byteArrayOutputStream);
        } catch (Exception e11) {
            e = e11;
            byteArrayOutputStream2 = byteArrayOutputStream;
            throw new IOException("Failed to save WebP file", e);
        } catch (Throwable th2) {
            th = th2;
            s1.c.b(byteArrayOutputStream);
            throw th;
        }
    }

    public final void E(String str, String str2) {
        e eVar;
        String str3;
        boolean z10;
        d dVar;
        Matcher matcher;
        String str4 = str;
        String str5 = str2;
        String str6 = "ExifInterface";
        if (("DateTime".equals(str4) || "DateTimeOriginal".equals(str4) || "DateTimeDigitized".equals(str4)) && str5 != null) {
            boolean find = f25000f0.matcher(str5).find();
            boolean find2 = f25001g0.matcher(str5).find();
            if (str2.length() != 19 || (!find && !find2)) {
                Log.w("ExifInterface", "Invalid value for " + str4 + " : " + str5);
                return;
            } else if (find2) {
                str5 = str5.replaceAll("-", ":");
            }
        }
        boolean equals = "ISOSpeedRatings".equals(str4);
        boolean z11 = f25002t;
        if (equals) {
            if (z11) {
                Log.d("ExifInterface", "setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str4 = "PhotographicSensitivity";
        }
        int i10 = 2;
        int i11 = 1;
        if (str5 != null && Z.contains(str4)) {
            if (str4.equals("GPSTimeStamp")) {
                if (!f24999e0.matcher(str5).find()) {
                    Log.w("ExifInterface", "Invalid value for " + str4 + " : " + str5);
                    return;
                }
                str5 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1";
            } else {
                try {
                    str5 = new f(Double.parseDouble(str5)).toString();
                } catch (NumberFormatException unused) {
                    Log.w("ExifInterface", "Invalid value for " + str4 + " : " + str5);
                    return;
                }
            }
        }
        char c10 = 0;
        int i12 = 0;
        while (i12 < V.length) {
            if ((i12 != 4 || this.f25016h) && (eVar = Y[i12].get(str4)) != null) {
                HashMap<String, d>[] hashMapArr = this.f25013e;
                if (str5 == null) {
                    hashMapArr[i12].remove(str4);
                } else {
                    Pair<Integer, Integer> q4 = q(str5);
                    int intValue = ((Integer) q4.first).intValue();
                    int i13 = -1;
                    int i14 = eVar.f25044c;
                    if (i14 != intValue && i14 != ((Integer) q4.second).intValue()) {
                        int i15 = eVar.f25045d;
                        if (i15 != -1 && (i15 == ((Integer) q4.first).intValue() || i15 == ((Integer) q4.second).intValue())) {
                            i14 = i15;
                        } else if (i14 != i11 && i14 != 7 && i14 != i10) {
                            if (z11) {
                                StringBuilder b10 = androidx.activity.result.d.b("Given tag (", str4, ") value didn't match with one of expected formats: ");
                                String[] strArr = R;
                                b10.append(strArr[i14]);
                                String str7 = HttpUrl.FRAGMENT_ENCODE_SET;
                                b10.append(i15 == -1 ? HttpUrl.FRAGMENT_ENCODE_SET : ", " + strArr[i15]);
                                b10.append(" (guess: ");
                                b10.append(strArr[((Integer) q4.first).intValue()]);
                                if (((Integer) q4.second).intValue() != -1) {
                                    str7 = ", " + strArr[((Integer) q4.second).intValue()];
                                }
                                b10.append(str7);
                                b10.append(")");
                                Log.d(str6, b10.toString());
                            }
                        }
                    }
                    String str8 = "/";
                    int[] iArr = S;
                    switch (i14) {
                        case 1:
                            str3 = str6;
                            z10 = z11;
                            HashMap<String, d> hashMap = hashMapArr[i12];
                            if (str5.length() == 1) {
                                c10 = 0;
                                if (str5.charAt(0) >= '0' && str5.charAt(0) <= '1') {
                                    dVar = new d(1, new byte[]{(byte) (str5.charAt(0) - '0')}, 1);
                                    hashMap.put(str4, dVar);
                                    str6 = str3;
                                    break;
                                }
                            } else {
                                c10 = 0;
                            }
                            byte[] bytes = str5.getBytes(f24996b0);
                            dVar = new d(1, bytes, bytes.length);
                            hashMap.put(str4, dVar);
                            str6 = str3;
                            break;
                        case 2:
                        case 7:
                            str3 = str6;
                            z10 = z11;
                            hashMapArr[i12].put(str4, d.a(str5));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 3:
                            str3 = str6;
                            z10 = z11;
                            String[] split = str5.split(",", -1);
                            int[] iArr2 = new int[split.length];
                            for (int i16 = 0; i16 < split.length; i16++) {
                                iArr2[i16] = Integer.parseInt(split[i16]);
                            }
                            hashMapArr[i12].put(str4, d.f(iArr2, this.f25015g));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 4:
                            str3 = str6;
                            z10 = z11;
                            String[] split2 = str5.split(",", -1);
                            long[] jArr = new long[split2.length];
                            for (int i17 = 0; i17 < split2.length; i17++) {
                                jArr[i17] = Long.parseLong(split2[i17]);
                            }
                            hashMapArr[i12].put(str4, d.c(jArr, this.f25015g));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 5:
                            str3 = str6;
                            z10 = z11;
                            int i18 = -1;
                            String[] split3 = str5.split(",", -1);
                            f[] fVarArr = new f[split3.length];
                            int i19 = 0;
                            while (i19 < split3.length) {
                                String[] split4 = split3[i19].split("/", i18);
                                fVarArr[i19] = new f((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1]));
                                i19++;
                                i18 = -1;
                            }
                            hashMapArr[i12].put(str4, d.d(fVarArr, this.f25015g));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 6:
                        case 8:
                        case 11:
                        default:
                            str3 = str6;
                            z10 = z11;
                            if (z10) {
                                str6 = str3;
                                s1.a.a("Data format isn't one of expected formats: ", i14, str6);
                                break;
                            }
                            str6 = str3;
                            break;
                        case 9:
                            str3 = str6;
                            z10 = z11;
                            String[] split5 = str5.split(",", -1);
                            int length = split5.length;
                            int[] iArr3 = new int[length];
                            for (int i20 = 0; i20 < split5.length; i20++) {
                                iArr3[i20] = Integer.parseInt(split5[i20]);
                            }
                            HashMap<String, d> hashMap2 = hashMapArr[i12];
                            ByteOrder byteOrder = this.f25015g;
                            ByteBuffer wrap = ByteBuffer.wrap(new byte[iArr[9] * length]);
                            wrap.order(byteOrder);
                            for (int i21 = 0; i21 < length; i21++) {
                                wrap.putInt(iArr3[i21]);
                            }
                            hashMap2.put(str4, new d(9, wrap.array(), length));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 10:
                            String[] split6 = str5.split(",", -1);
                            int length2 = split6.length;
                            f[] fVarArr2 = new f[length2];
                            int i22 = 0;
                            while (i22 < split6.length) {
                                String[] split7 = split6[i22].split(str8, i13);
                                fVarArr2[i22] = new f((long) Double.parseDouble(split7[c10]), (long) Double.parseDouble(split7[1]));
                                i22++;
                                c10 = 0;
                                i13 = -1;
                                str8 = str8;
                                z11 = z11;
                                str6 = str6;
                            }
                            str3 = str6;
                            z10 = z11;
                            HashMap<String, d> hashMap3 = hashMapArr[i12];
                            ByteOrder byteOrder2 = this.f25015g;
                            ByteBuffer wrap2 = ByteBuffer.wrap(new byte[iArr[10] * length2]);
                            wrap2.order(byteOrder2);
                            for (int i23 = 0; i23 < length2; i23++) {
                                f fVar = fVarArr2[i23];
                                wrap2.putInt((int) fVar.f25046a);
                                wrap2.putInt((int) fVar.f25047b);
                            }
                            hashMap3.put(str4, new d(10, wrap2.array(), length2));
                            c10 = 0;
                            str6 = str3;
                            break;
                        case 12:
                            String[] split8 = str5.split(",", -1);
                            int length3 = split8.length;
                            double[] dArr = new double[length3];
                            for (int i24 = 0; i24 < split8.length; i24++) {
                                dArr[i24] = Double.parseDouble(split8[i24]);
                            }
                            HashMap<String, d> hashMap4 = hashMapArr[i12];
                            ByteOrder byteOrder3 = this.f25015g;
                            ByteBuffer wrap3 = ByteBuffer.wrap(new byte[iArr[12] * length3]);
                            wrap3.order(byteOrder3);
                            for (int i25 = 0; i25 < length3; i25++) {
                                wrap3.putDouble(dArr[i25]);
                            }
                            hashMap4.put(str4, new d(12, wrap3.array(), length3));
                            break;
                    }
                    i12++;
                    i10 = 2;
                    i11 = 1;
                    z11 = z10;
                }
            }
            z10 = z11;
            i12++;
            i10 = 2;
            i11 = 1;
            z11 = z10;
        }
    }

    public final void F(C0199b c0199b) {
        boolean z10;
        d dVar;
        int h10;
        HashMap<String, d> hashMap = this.f25013e[4];
        d dVar2 = hashMap.get("Compression");
        if (dVar2 == null) {
            this.f25022n = 6;
            r(c0199b, hashMap);
            return;
        }
        int h11 = dVar2.h(this.f25015g);
        this.f25022n = h11;
        int i10 = 1;
        if (h11 != 1) {
            if (h11 == 6) {
                r(c0199b, hashMap);
                return;
            } else if (h11 != 7) {
                return;
            }
        }
        d dVar3 = hashMap.get("BitsPerSample");
        if (dVar3 != null) {
            int[] iArr = (int[]) dVar3.j(this.f25015g);
            int[] iArr2 = f25005w;
            if (Arrays.equals(iArr2, iArr) || (this.f25012d == 3 && (dVar = hashMap.get("PhotometricInterpretation")) != null && (((h10 = dVar.h(this.f25015g)) == 1 && Arrays.equals(iArr, f25006x)) || (h10 == 6 && Arrays.equals(iArr, iArr2))))) {
                z10 = true;
                if (z10) {
                    return;
                }
                d dVar4 = hashMap.get("StripOffsets");
                d dVar5 = hashMap.get("StripByteCounts");
                if (dVar4 == null || dVar5 == null) {
                    return;
                }
                long[] c10 = s1.c.c(dVar4.j(this.f25015g));
                long[] c11 = s1.c.c(dVar5.j(this.f25015g));
                if (c10 == null || c10.length == 0) {
                    Log.w("ExifInterface", "stripOffsets should not be null or have zero length.");
                    return;
                } else if (c11 == null || c11.length == 0) {
                    Log.w("ExifInterface", "stripByteCounts should not be null or have zero length.");
                    return;
                } else if (c10.length != c11.length) {
                    Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                    return;
                } else {
                    long j10 = 0;
                    for (long j11 : c11) {
                        j10 += j11;
                    }
                    int i11 = (int) j10;
                    byte[] bArr = new byte[i11];
                    this.f25018j = true;
                    this.f25017i = true;
                    this.f25016h = true;
                    int i12 = 0;
                    int i13 = 0;
                    int i14 = 0;
                    while (i12 < c10.length) {
                        int i15 = (int) c10[i12];
                        int i16 = (int) c11[i12];
                        if (i12 < c10.length - i10 && i15 + i16 != c10[i12 + 1]) {
                            this.f25018j = false;
                        }
                        int i17 = i15 - i13;
                        if (i17 < 0) {
                            Log.d("ExifInterface", "Invalid strip offset value");
                            return;
                        }
                        long j12 = i17;
                        if (c0199b.skip(j12) != j12) {
                            Log.d("ExifInterface", "Failed to skip " + i17 + " bytes.");
                            return;
                        }
                        int i18 = i13 + i17;
                        byte[] bArr2 = new byte[i16];
                        if (c0199b.read(bArr2) != i16) {
                            Log.d("ExifInterface", "Failed to read " + i16 + " bytes.");
                            return;
                        }
                        i13 = i18 + i16;
                        System.arraycopy(bArr2, 0, bArr, i14, i16);
                        i14 += i16;
                        i12++;
                        i10 = 1;
                    }
                    this.f25021m = bArr;
                    if (this.f25018j) {
                        this.f25019k = (int) c10[0];
                        this.f25020l = i11;
                        return;
                    }
                    return;
                }
            }
        }
        if (f25002t) {
            Log.d("ExifInterface", "Unsupported data type value");
        }
        z10 = false;
        if (z10) {
        }
    }

    public final void G(int i10, int i11) {
        HashMap<String, d>[] hashMapArr = this.f25013e;
        boolean isEmpty = hashMapArr[i10].isEmpty();
        boolean z10 = f25002t;
        if (isEmpty || hashMapArr[i11].isEmpty()) {
            if (z10) {
                Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
                return;
            }
            return;
        }
        d dVar = hashMapArr[i10].get("ImageLength");
        d dVar2 = hashMapArr[i10].get("ImageWidth");
        d dVar3 = hashMapArr[i11].get("ImageLength");
        d dVar4 = hashMapArr[i11].get("ImageWidth");
        if (dVar == null || dVar2 == null) {
            if (z10) {
                Log.d("ExifInterface", "First image does not contain valid size information");
            }
        } else if (dVar3 == null || dVar4 == null) {
            if (z10) {
                Log.d("ExifInterface", "Second image does not contain valid size information");
            }
        } else {
            int h10 = dVar.h(this.f25015g);
            int h11 = dVar2.h(this.f25015g);
            int h12 = dVar3.h(this.f25015g);
            int h13 = dVar4.h(this.f25015g);
            if (h10 >= h12 || h11 >= h13) {
                return;
            }
            HashMap<String, d> hashMap = hashMapArr[i10];
            hashMapArr[i10] = hashMapArr[i11];
            hashMapArr[i11] = hashMap;
        }
    }

    public final void H(g gVar, int i10) {
        d e10;
        d e11;
        HashMap<String, d>[] hashMapArr = this.f25013e;
        d dVar = hashMapArr[i10].get("DefaultCropSize");
        d dVar2 = hashMapArr[i10].get("SensorTopBorder");
        d dVar3 = hashMapArr[i10].get("SensorLeftBorder");
        d dVar4 = hashMapArr[i10].get("SensorBottomBorder");
        d dVar5 = hashMapArr[i10].get("SensorRightBorder");
        if (dVar != null) {
            if (dVar.f25038a == 5) {
                f[] fVarArr = (f[]) dVar.j(this.f25015g);
                if (fVarArr == null || fVarArr.length != 2) {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(fVarArr));
                    return;
                }
                e10 = d.d(new f[]{fVarArr[0]}, this.f25015g);
                e11 = d.d(new f[]{fVarArr[1]}, this.f25015g);
            } else {
                int[] iArr = (int[]) dVar.j(this.f25015g);
                if (iArr == null || iArr.length != 2) {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(iArr));
                    return;
                }
                e10 = d.e(iArr[0], this.f25015g);
                e11 = d.e(iArr[1], this.f25015g);
            }
            hashMapArr[i10].put("ImageWidth", e10);
            hashMapArr[i10].put("ImageLength", e11);
        } else if (dVar2 != null && dVar3 != null && dVar4 != null && dVar5 != null) {
            int h10 = dVar2.h(this.f25015g);
            int h11 = dVar4.h(this.f25015g);
            int h12 = dVar5.h(this.f25015g);
            int h13 = dVar3.h(this.f25015g);
            if (h11 <= h10 || h12 <= h13) {
                return;
            }
            d e12 = d.e(h11 - h10, this.f25015g);
            d e13 = d.e(h12 - h13, this.f25015g);
            hashMapArr[i10].put("ImageLength", e12);
            hashMapArr[i10].put("ImageWidth", e13);
        } else {
            d dVar6 = hashMapArr[i10].get("ImageLength");
            d dVar7 = hashMapArr[i10].get("ImageWidth");
            if (dVar6 == null || dVar7 == null) {
                d dVar8 = hashMapArr[i10].get("JPEGInterchangeFormat");
                d dVar9 = hashMapArr[i10].get("JPEGInterchangeFormatLength");
                if (dVar8 == null || dVar9 == null) {
                    return;
                }
                int h14 = dVar8.h(this.f25015g);
                int h15 = dVar8.h(this.f25015g);
                gVar.b(h14);
                byte[] bArr = new byte[h15];
                gVar.read(bArr);
                h(new C0199b(bArr), h14, i10);
            }
        }
    }

    public final void I() {
        G(0, 5);
        G(0, 4);
        G(5, 4);
        HashMap<String, d>[] hashMapArr = this.f25013e;
        d dVar = hashMapArr[1].get("PixelXDimension");
        d dVar2 = hashMapArr[1].get("PixelYDimension");
        if (dVar != null && dVar2 != null) {
            hashMapArr[0].put("ImageWidth", dVar);
            hashMapArr[0].put("ImageLength", dVar2);
        }
        if (hashMapArr[4].isEmpty() && s(hashMapArr[5])) {
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (!s(hashMapArr[4])) {
            Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
        }
        A(0, "ThumbnailOrientation", "Orientation");
        A(0, "ThumbnailImageLength", "ImageLength");
        A(0, "ThumbnailImageWidth", "ImageWidth");
        A(5, "ThumbnailOrientation", "Orientation");
        A(5, "ThumbnailImageLength", "ImageLength");
        A(5, "ThumbnailImageWidth", "ImageWidth");
        A(4, "Orientation", "ThumbnailOrientation");
        A(4, "ImageLength", "ThumbnailImageLength");
        A(4, "ImageWidth", "ThumbnailImageWidth");
    }

    public final void J(c cVar) {
        HashMap<String, d>[] hashMapArr;
        int[] iArr;
        Object[] objArr;
        e[][] eVarArr = V;
        int[] iArr2 = new int[eVarArr.length];
        int[] iArr3 = new int[eVarArr.length];
        e[] eVarArr2 = W;
        for (e eVar : eVarArr2) {
            z(eVar.f25043b);
        }
        if (this.f25016h) {
            if (this.f25017i) {
                z("StripOffsets");
                z("StripByteCounts");
            } else {
                z("JPEGInterchangeFormat");
                z("JPEGInterchangeFormatLength");
            }
        }
        int i10 = 0;
        while (true) {
            int length = eVarArr.length;
            hashMapArr = this.f25013e;
            if (i10 >= length) {
                break;
            }
            Object[] array = hashMapArr[i10].entrySet().toArray();
            int length2 = array.length;
            int i11 = 0;
            while (i11 < length2) {
                Map.Entry entry = (Map.Entry) array[i11];
                if (entry.getValue() == null) {
                    objArr = array;
                    hashMapArr[i10].remove(entry.getKey());
                } else {
                    objArr = array;
                }
                i11++;
                array = objArr;
            }
            i10++;
        }
        if (!hashMapArr[1].isEmpty()) {
            hashMapArr[0].put(eVarArr2[1].f25043b, d.b(0L, this.f25015g));
        }
        if (!hashMapArr[2].isEmpty()) {
            hashMapArr[0].put(eVarArr2[2].f25043b, d.b(0L, this.f25015g));
        }
        if (!hashMapArr[3].isEmpty()) {
            hashMapArr[1].put(eVarArr2[3].f25043b, d.b(0L, this.f25015g));
        }
        if (this.f25016h) {
            if (this.f25017i) {
                hashMapArr[4].put("StripOffsets", d.e(0, this.f25015g));
                hashMapArr[4].put("StripByteCounts", d.e(this.f25020l, this.f25015g));
            } else {
                hashMapArr[4].put("JPEGInterchangeFormat", d.b(0L, this.f25015g));
                hashMapArr[4].put("JPEGInterchangeFormatLength", d.b(this.f25020l, this.f25015g));
            }
        }
        int i12 = 0;
        while (true) {
            int length3 = eVarArr.length;
            iArr = S;
            if (i12 >= length3) {
                break;
            }
            int i13 = 0;
            for (Map.Entry<String, d> entry2 : hashMapArr[i12].entrySet()) {
                d value = entry2.getValue();
                value.getClass();
                int i14 = iArr[value.f25038a] * value.f25039b;
                if (i14 > 4) {
                    i13 += i14;
                }
            }
            iArr3[i12] = iArr3[i12] + i13;
            i12++;
        }
        int i15 = 8;
        for (int i16 = 0; i16 < eVarArr.length; i16++) {
            if (!hashMapArr[i16].isEmpty()) {
                iArr2[i16] = i15;
                i15 = (hashMapArr[i16].size() * 12) + 2 + 4 + iArr3[i16] + i15;
            }
        }
        if (this.f25016h) {
            if (this.f25017i) {
                hashMapArr[4].put("StripOffsets", d.e(i15, this.f25015g));
            } else {
                hashMapArr[4].put("JPEGInterchangeFormat", d.b(i15, this.f25015g));
            }
            this.f25019k = i15;
            i15 += this.f25020l;
        }
        if (this.f25012d == 4) {
            i15 += 8;
        }
        if (f25002t) {
            for (int i17 = 0; i17 < eVarArr.length; i17++) {
                Log.d("ExifInterface", String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d", Integer.valueOf(i17), Integer.valueOf(iArr2[i17]), Integer.valueOf(hashMapArr[i17].size()), Integer.valueOf(iArr3[i17]), Integer.valueOf(i15)));
            }
        }
        if (!hashMapArr[1].isEmpty()) {
            hashMapArr[0].put(eVarArr2[1].f25043b, d.b(iArr2[1], this.f25015g));
        }
        if (!hashMapArr[2].isEmpty()) {
            hashMapArr[0].put(eVarArr2[2].f25043b, d.b(iArr2[2], this.f25015g));
        }
        if (!hashMapArr[3].isEmpty()) {
            hashMapArr[1].put(eVarArr2[3].f25043b, d.b(iArr2[3], this.f25015g));
        }
        int i18 = this.f25012d;
        if (i18 == 4) {
            cVar.k((short) i15);
            cVar.write(f24997c0);
        } else if (i18 == 13) {
            cVar.b(i15);
            cVar.write(F);
        } else if (i18 == 14) {
            cVar.write(K);
            cVar.b(i15);
        }
        cVar.k(this.f25015g == ByteOrder.BIG_ENDIAN ? (short) 19789 : (short) 18761);
        cVar.f25037s = this.f25015g;
        cVar.k((short) 42);
        cVar.b((int) 8);
        for (int i19 = 0; i19 < eVarArr.length; i19++) {
            if (!hashMapArr[i19].isEmpty()) {
                cVar.k((short) hashMapArr[i19].size());
                int size = (hashMapArr[i19].size() * 12) + iArr2[i19] + 2 + 4;
                for (Map.Entry<String, d> entry3 : hashMapArr[i19].entrySet()) {
                    int i20 = Y[i19].get(entry3.getKey()).f25042a;
                    d value2 = entry3.getValue();
                    value2.getClass();
                    int i21 = iArr[value2.f25038a] * value2.f25039b;
                    cVar.k((short) i20);
                    cVar.k((short) value2.f25038a);
                    cVar.b(value2.f25039b);
                    if (i21 > 4) {
                        cVar.b(size);
                        size += i21;
                    } else {
                        cVar.write(value2.f25041d);
                        if (i21 < 4) {
                            while (i21 < 4) {
                                cVar.a(0);
                                i21++;
                            }
                        }
                    }
                }
                if (i19 != 0 || hashMapArr[4].isEmpty()) {
                    cVar.b((int) 0);
                } else {
                    cVar.b(iArr2[4]);
                }
                for (Map.Entry<String, d> entry4 : hashMapArr[i19].entrySet()) {
                    byte[] bArr = entry4.getValue().f25041d;
                    if (bArr.length > 4) {
                        cVar.write(bArr, 0, bArr.length);
                    }
                }
            }
        }
        if (this.f25016h) {
            cVar.write(o());
        }
        if (this.f25012d == 14 && i15 % 2 == 1) {
            cVar.a(0);
        }
        cVar.f25037s = ByteOrder.BIG_ENDIAN;
    }

    public final void a() {
        String d10 = d("DateTimeOriginal");
        HashMap<String, d>[] hashMapArr = this.f25013e;
        if (d10 != null && d("DateTime") == null) {
            hashMapArr[0].put("DateTime", d.a(d10));
        }
        if (d("ImageWidth") == null) {
            hashMapArr[0].put("ImageWidth", d.b(0L, this.f25015g));
        }
        if (d("ImageLength") == null) {
            hashMapArr[0].put("ImageLength", d.b(0L, this.f25015g));
        }
        if (d("Orientation") == null) {
            hashMapArr[0].put("Orientation", d.b(0L, this.f25015g));
        }
        if (d("LightSource") == null) {
            hashMapArr[1].put("LightSource", d.b(0L, this.f25015g));
        }
    }

    public final String d(String str) {
        if (str != null) {
            d f10 = f(str);
            if (f10 != null) {
                if (!Z.contains(str)) {
                    return f10.i(this.f25015g);
                }
                if (str.equals("GPSTimeStamp")) {
                    int i10 = f10.f25038a;
                    if (i10 != 5 && i10 != 10) {
                        Log.w("ExifInterface", "GPS Timestamp format is not rational. format=" + i10);
                        return null;
                    }
                    f[] fVarArr = (f[]) f10.j(this.f25015g);
                    if (fVarArr == null || fVarArr.length != 3) {
                        Log.w("ExifInterface", "Invalid GPS Timestamp array. array=" + Arrays.toString(fVarArr));
                        return null;
                    }
                    f fVar = fVarArr[0];
                    f fVar2 = fVarArr[1];
                    f fVar3 = fVarArr[2];
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) fVar.f25046a) / ((float) fVar.f25047b))), Integer.valueOf((int) (((float) fVar2.f25046a) / ((float) fVar2.f25047b))), Integer.valueOf((int) (((float) fVar3.f25046a) / ((float) fVar3.f25047b))));
                }
                try {
                    return Double.toString(f10.g(this.f25015g));
                } catch (NumberFormatException unused) {
                }
            }
            return null;
        }
        throw new NullPointerException("tag shouldn't be null");
    }

    public final int e(int i10, String str) {
        d f10 = f(str);
        if (f10 == null) {
            return i10;
        }
        try {
            return f10.h(this.f25015g);
        } catch (NumberFormatException unused) {
            return i10;
        }
    }

    public final d f(String str) {
        if (str != null) {
            if ("ISOSpeedRatings".equals(str)) {
                if (f25002t) {
                    Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
                }
                str = "PhotographicSensitivity";
            }
            for (int i10 = 0; i10 < V.length; i10++) {
                d dVar = this.f25013e[i10].get(str);
                if (dVar != null) {
                    return dVar;
                }
            }
            return null;
        }
        throw new NullPointerException("tag shouldn't be null");
    }

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

    public final void h(C0199b c0199b, int i10, int i11) {
        byte readByte;
        byte readByte2;
        boolean z10;
        boolean z11;
        boolean z12 = f25002t;
        if (z12) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + c0199b);
        }
        c0199b.f25033s = ByteOrder.BIG_ENDIAN;
        byte b10 = -1;
        if (c0199b.readByte() != -1) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        } else if (c0199b.readByte() != -40) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        } else {
            int i12 = 2;
            int i13 = 2;
            while (true) {
                if (c0199b.readByte() != b10) {
                    throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
                }
                int i14 = i13 + 1;
                byte readByte3 = c0199b.readByte();
                if (z12) {
                    Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                }
                int i15 = i14 + 1;
                if (readByte3 != -39 && readByte3 != -38) {
                    int readUnsignedShort = c0199b.readUnsignedShort() - i12;
                    int i16 = i15 + i12;
                    if (z12) {
                        Log.d("ExifInterface", "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")");
                    }
                    if (readUnsignedShort < 0) {
                        throw new IOException("Invalid length");
                    }
                    HashMap<String, d>[] hashMapArr = this.f25013e;
                    if (readByte3 == -31) {
                        byte[] bArr = new byte[readUnsignedShort];
                        c0199b.readFully(bArr);
                        int i17 = i16 + readUnsignedShort;
                        byte[] bArr2 = f24997c0;
                        if (bArr2 != null && readUnsignedShort >= bArr2.length) {
                            for (int i18 = 0; i18 < bArr2.length; i18++) {
                                if (bArr[i18] == bArr2[i18]) {
                                }
                            }
                            z10 = true;
                            if (z10) {
                                byte[] bArr3 = f24998d0;
                                if (bArr3 != null && readUnsignedShort >= bArr3.length) {
                                    for (int i19 = 0; i19 < bArr3.length; i19++) {
                                        if (bArr[i19] == bArr3[i19]) {
                                        }
                                    }
                                    z11 = true;
                                    if (z11) {
                                        int length = bArr3.length + i16;
                                        byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                                        if (d("Xmp") == null) {
                                            hashMapArr[0].put("Xmp", new d(length, copyOfRange, 1, copyOfRange.length));
                                            this.f25027s = true;
                                        }
                                    }
                                }
                                z11 = false;
                                if (z11) {
                                }
                            } else {
                                byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                                this.f25023o = i10 + i16 + bArr2.length;
                                x(copyOfRange2, i11);
                                F(new C0199b(copyOfRange2));
                            }
                            i16 = i17;
                        }
                        z10 = false;
                        if (z10) {
                        }
                        i16 = i17;
                    } else if (readByte3 != -2) {
                        switch (readByte3) {
                            default:
                                switch (readByte3) {
                                    default:
                                        switch (readByte3) {
                                            default:
                                                switch (readByte3) {
                                                }
                                            case -55:
                                            case -54:
                                            case -53:
                                                c0199b.a(1);
                                                hashMapArr[i11].put(i11 != 4 ? "ImageLength" : "ThumbnailImageLength", d.b(c0199b.readUnsignedShort(), this.f25015g));
                                                hashMapArr[i11].put(i11 != 4 ? "ImageWidth" : "ThumbnailImageWidth", d.b(c0199b.readUnsignedShort(), this.f25015g));
                                                readUnsignedShort -= 5;
                                                break;
                                        }
                                    case -59:
                                    case -58:
                                    case -57:
                                        break;
                                }
                            case -64:
                            case -63:
                            case -62:
                            case -61:
                                break;
                        }
                        if (readUnsignedShort >= 0) {
                            throw new IOException("Invalid length");
                        }
                        c0199b.a(readUnsignedShort);
                        i13 = i16 + readUnsignedShort;
                        i12 = 2;
                        b10 = -1;
                    } else {
                        byte[] bArr4 = new byte[readUnsignedShort];
                        if (c0199b.read(bArr4) != readUnsignedShort) {
                            throw new IOException("Invalid exif");
                        }
                        if (d("UserComment") == null) {
                            hashMapArr[1].put("UserComment", d.a(new String(bArr4, f24996b0)));
                        }
                    }
                    readUnsignedShort = 0;
                    if (readUnsignedShort >= 0) {
                    }
                }
            }
        }
    }

    public final int i(BufferedInputStream bufferedInputStream) {
        boolean z10;
        boolean z11;
        C0199b c0199b;
        C0199b c0199b2;
        boolean z12;
        C0199b c0199b3;
        C0199b c0199b4;
        boolean z13;
        C0199b c0199b5;
        C0199b c0199b6;
        boolean z14;
        boolean z15;
        boolean z16;
        long j10;
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr2 = f25007y;
            if (i10 >= bArr2.length) {
                z10 = true;
                break;
            } else if (bArr[i10] != bArr2[i10]) {
                z10 = false;
                break;
            } else {
                i10++;
            }
        }
        if (z10) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i11 = 0;
        while (true) {
            if (i11 >= bytes.length) {
                z11 = true;
                break;
            } else if (bArr[i11] != bytes[i11]) {
                z11 = false;
                break;
            } else {
                i11++;
            }
        }
        if (z11) {
            return 9;
        }
        try {
            c0199b2 = new C0199b(bArr);
            try {
                long readInt = c0199b2.readInt();
                byte[] bArr3 = new byte[4];
                c0199b2.read(bArr3);
                if (Arrays.equals(bArr3, f25008z)) {
                    if (readInt == 1) {
                        readInt = c0199b2.readLong();
                        j10 = 16;
                        if (readInt < 16) {
                        }
                    } else {
                        j10 = 8;
                    }
                    long j11 = 5000;
                    if (readInt > j11) {
                        readInt = j11;
                    }
                    long j12 = readInt - j10;
                    if (j12 >= 8) {
                        byte[] bArr4 = new byte[4];
                        boolean z17 = false;
                        boolean z18 = false;
                        for (long j13 = 0; j13 < j12 / 4 && c0199b2.read(bArr4) == 4; j13++) {
                            if (j13 != 1) {
                                if (Arrays.equals(bArr4, A)) {
                                    z17 = true;
                                } else if (Arrays.equals(bArr4, B)) {
                                    z18 = true;
                                }
                                if (z17 && z18) {
                                    c0199b2.close();
                                    z12 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e10) {
                e = e10;
                try {
                    if (f25002t) {
                        Log.d("ExifInterface", "Exception parsing HEIF file type box.", e);
                    }
                } catch (Throwable th) {
                    th = th;
                    c0199b = c0199b2;
                    c0199b2 = c0199b;
                    if (c0199b2 != null) {
                        c0199b2.close();
                    }
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
                if (c0199b2 != null) {
                }
                throw th;
            }
        } catch (Exception e11) {
            e = e11;
            c0199b2 = null;
        } catch (Throwable th3) {
            th = th3;
            c0199b = null;
            c0199b2 = c0199b;
            if (c0199b2 != null) {
            }
            throw th;
        }
        c0199b2.close();
        z12 = false;
        if (z12) {
            return 12;
        }
        try {
            c0199b4 = new C0199b(bArr);
            try {
                ByteOrder w10 = w(c0199b4);
                this.f25015g = w10;
                c0199b4.f25033s = w10;
                short readShort = c0199b4.readShort();
                z13 = readShort == 20306 || readShort == 21330;
                c0199b4.close();
            } catch (Exception unused) {
                if (c0199b4 != null) {
                    c0199b4.close();
                }
                z13 = false;
                if (z13) {
                }
            } catch (Throwable th4) {
                th = th4;
                c0199b3 = c0199b4;
                if (c0199b3 != null) {
                    c0199b3.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
            c0199b4 = null;
        } catch (Throwable th5) {
            th = th5;
            c0199b3 = null;
        }
        if (z13) {
            try {
                C0199b c0199b7 = new C0199b(bArr);
                try {
                    ByteOrder w11 = w(c0199b7);
                    this.f25015g = w11;
                    c0199b7.f25033s = w11;
                    z14 = c0199b7.readShort() == 85;
                    c0199b7.close();
                } catch (Exception unused3) {
                    c0199b6 = c0199b7;
                    if (c0199b6 != null) {
                        c0199b6.close();
                    }
                    z14 = false;
                    if (z14) {
                    }
                } catch (Throwable th6) {
                    th = th6;
                    c0199b5 = c0199b7;
                    if (c0199b5 != null) {
                        c0199b5.close();
                    }
                    throw th;
                }
            } catch (Exception unused4) {
                c0199b6 = null;
            } catch (Throwable th7) {
                th = th7;
                c0199b5 = null;
            }
            if (z14) {
                int i12 = 0;
                while (true) {
                    byte[] bArr5 = E;
                    if (i12 >= bArr5.length) {
                        z15 = true;
                        break;
                    } else if (bArr[i12] != bArr5[i12]) {
                        z15 = false;
                        break;
                    } else {
                        i12++;
                    }
                }
                if (z15) {
                    return 13;
                }
                int i13 = 0;
                while (true) {
                    byte[] bArr6 = I;
                    if (i13 >= bArr6.length) {
                        int i14 = 0;
                        while (true) {
                            byte[] bArr7 = J;
                            if (i14 >= bArr7.length) {
                                z16 = true;
                                break;
                            } else if (bArr[bArr6.length + i14 + 4] != bArr7[i14]) {
                                break;
                            } else {
                                i14++;
                            }
                        }
                    } else if (bArr[i13] != bArr6[i13]) {
                        break;
                    } else {
                        i13++;
                    }
                }
                z16 = false;
                return z16 ? 14 : 0;
            }
            return 10;
        }
        return 7;
    }

    public final void j(g gVar) {
        int i10;
        int i11;
        m(gVar);
        HashMap<String, d>[] hashMapArr = this.f25013e;
        d dVar = hashMapArr[1].get("MakerNote");
        if (dVar != null) {
            g gVar2 = new g(dVar.f25041d);
            gVar2.f25033s = this.f25015g;
            byte[] bArr = C;
            byte[] bArr2 = new byte[bArr.length];
            gVar2.readFully(bArr2);
            gVar2.b(0L);
            byte[] bArr3 = D;
            byte[] bArr4 = new byte[bArr3.length];
            gVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                gVar2.b(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                gVar2.b(12L);
            }
            y(gVar2, 6);
            d dVar2 = hashMapArr[7].get("PreviewImageStart");
            d dVar3 = hashMapArr[7].get("PreviewImageLength");
            if (dVar2 != null && dVar3 != null) {
                hashMapArr[5].put("JPEGInterchangeFormat", dVar2);
                hashMapArr[5].put("JPEGInterchangeFormatLength", dVar3);
            }
            d dVar4 = hashMapArr[8].get("AspectFrame");
            if (dVar4 != null) {
                int[] iArr = (int[]) dVar4.j(this.f25015g);
                if (iArr == null || iArr.length != 4) {
                    Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
                    return;
                }
                int i12 = iArr[2];
                int i13 = iArr[0];
                if (i12 <= i13 || (i10 = iArr[3]) <= (i11 = iArr[1])) {
                    return;
                }
                int i14 = (i12 - i13) + 1;
                int i15 = (i10 - i11) + 1;
                if (i14 < i15) {
                    int i16 = i14 + i15;
                    i15 = i16 - i15;
                    i14 = i16 - i15;
                }
                d e10 = d.e(i14, this.f25015g);
                d e11 = d.e(i15, this.f25015g);
                hashMapArr[0].put("ImageWidth", e10);
                hashMapArr[0].put("ImageLength", e11);
            }
        }
    }

    public final void k(C0199b c0199b) {
        if (f25002t) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + c0199b);
        }
        c0199b.f25033s = ByteOrder.BIG_ENDIAN;
        byte[] bArr = E;
        c0199b.a(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = c0199b.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (c0199b.read(bArr2) != 4) {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
                int i11 = i10 + 4;
                if (i11 == 16 && !Arrays.equals(bArr2, G)) {
                    throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                }
                if (Arrays.equals(bArr2, H)) {
                    return;
                }
                if (Arrays.equals(bArr2, F)) {
                    byte[] bArr3 = new byte[readInt];
                    if (c0199b.read(bArr3) != readInt) {
                        throw new IOException("Failed to read given length for given PNG chunk type: " + s1.c.a(bArr2));
                    }
                    int readInt2 = c0199b.readInt();
                    CRC32 crc32 = new CRC32();
                    crc32.update(bArr2);
                    crc32.update(bArr3);
                    if (((int) crc32.getValue()) == readInt2) {
                        this.f25023o = i11;
                        x(bArr3, 0);
                        I();
                        F(new C0199b(bArr3));
                        return;
                    }
                    throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                }
                int i12 = readInt + 4;
                c0199b.a(i12);
                length = i11 + i12;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void l(C0199b c0199b) {
        boolean z10 = f25002t;
        if (z10) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + c0199b);
        }
        c0199b.a(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        byte[] bArr3 = new byte[4];
        c0199b.read(bArr);
        c0199b.read(bArr2);
        c0199b.read(bArr3);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        int i12 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i11];
        c0199b.a(i10 - c0199b.f25034t);
        c0199b.read(bArr4);
        h(new C0199b(bArr4), i10, 5);
        c0199b.a(i12 - c0199b.f25034t);
        c0199b.f25033s = ByteOrder.BIG_ENDIAN;
        int readInt = c0199b.readInt();
        if (z10) {
            s1.a.a("numberOfDirectoryEntry: ", readInt, "ExifInterface");
        }
        for (int i13 = 0; i13 < readInt; i13++) {
            int readUnsignedShort = c0199b.readUnsignedShort();
            int readUnsignedShort2 = c0199b.readUnsignedShort();
            if (readUnsignedShort == U.f25042a) {
                short readShort = c0199b.readShort();
                short readShort2 = c0199b.readShort();
                d e10 = d.e(readShort, this.f25015g);
                d e11 = d.e(readShort2, this.f25015g);
                HashMap<String, d>[] hashMapArr = this.f25013e;
                hashMapArr[0].put("ImageLength", e10);
                hashMapArr[0].put("ImageWidth", e11);
                if (z10) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            c0199b.a(readUnsignedShort2);
        }
    }

    public final void m(g gVar) {
        u(gVar);
        y(gVar, 0);
        H(gVar, 0);
        H(gVar, 5);
        H(gVar, 4);
        I();
        if (this.f25012d == 8) {
            HashMap<String, d>[] hashMapArr = this.f25013e;
            d dVar = hashMapArr[1].get("MakerNote");
            if (dVar != null) {
                g gVar2 = new g(dVar.f25041d);
                gVar2.f25033s = this.f25015g;
                gVar2.a(6);
                y(gVar2, 9);
                d dVar2 = hashMapArr[9].get("ColorSpace");
                if (dVar2 != null) {
                    hashMapArr[1].put("ColorSpace", dVar2);
                }
            }
        }
    }

    public final void n(g gVar) {
        if (f25002t) {
            Log.d("ExifInterface", "getRw2Attributes starting with: " + gVar);
        }
        m(gVar);
        HashMap<String, d>[] hashMapArr = this.f25013e;
        d dVar = hashMapArr[0].get("JpgFromRaw");
        if (dVar != null) {
            h(new C0199b(dVar.f25041d), (int) dVar.f25040c, 5);
        }
        d dVar2 = hashMapArr[0].get("ISO");
        d dVar3 = hashMapArr[1].get("PhotographicSensitivity");
        if (dVar2 == null || dVar3 != null) {
            return;
        }
        hashMapArr[1].put("PhotographicSensitivity", dVar2);
    }

    public final byte[] o() {
        Closeable closeable;
        FileDescriptor fileDescriptor;
        Exception e10;
        FileDescriptor fileDescriptor2;
        FileInputStream fileInputStream;
        Closeable closeable2 = null;
        if (!this.f25016h) {
            return null;
        }
        ?? r32 = this.f25021m;
        try {
            if (r32 != 0) {
                return r32;
            }
            try {
                r32 = this.f25011c;
                try {
                    if (r32 != 0) {
                        try {
                            if (!r32.markSupported()) {
                                Log.d("ExifInterface", "Cannot read thumbnail from inputstream without mark/reset support");
                                s1.c.b(r32);
                                return null;
                            }
                            r32.reset();
                            fileInputStream = r32;
                        } catch (Exception e11) {
                            e10 = e11;
                            fileDescriptor2 = null;
                            Log.d("ExifInterface", "Encountered exception while getting thumbnail", e10);
                            s1.c.b(r32);
                            if (fileDescriptor2 != null) {
                            }
                            return null;
                        } catch (Throwable th) {
                            th = th;
                            Closeable closeable3 = closeable2;
                            closeable2 = r32;
                            fileDescriptor = closeable3;
                            s1.c.b(closeable2);
                            if (fileDescriptor != 0) {
                                try {
                                    c.a.a(fileDescriptor);
                                } catch (Exception unused) {
                                    Log.e("ExifInterfaceUtils", "Error closing fd.");
                                }
                            }
                            throw th;
                        }
                    } else if (this.f25009a == null) {
                        fileDescriptor = c.a.b(this.f25010b);
                        try {
                            c.a.c(fileDescriptor, 0L, OsConstants.SEEK_SET);
                            fileDescriptor2 = fileDescriptor;
                            r32 = new FileInputStream(fileDescriptor);
                            if (r32.skip(this.f25019k + this.f25023o) != this.f25019k + this.f25023o) {
                                byte[] bArr = new byte[this.f25020l];
                                if (r32.read(bArr) == this.f25020l) {
                                    this.f25021m = bArr;
                                    s1.c.b(r32);
                                    if (fileDescriptor2 != null) {
                                        try {
                                            c.a.a(fileDescriptor2);
                                        } catch (Exception unused2) {
                                            Log.e("ExifInterfaceUtils", "Error closing fd.");
                                        }
                                    }
                                    return bArr;
                                }
                                throw new IOException("Corrupted image");
                            }
                            throw new IOException("Corrupted image");
                        } catch (Exception e12) {
                            e10 = e12;
                            fileDescriptor2 = fileDescriptor;
                            r32 = 0;
                            Log.d("ExifInterface", "Encountered exception while getting thumbnail", e10);
                            s1.c.b(r32);
                            if (fileDescriptor2 != null) {
                            }
                            return null;
                        } catch (Throwable th2) {
                            th = th2;
                            s1.c.b(closeable2);
                            if (fileDescriptor != 0) {
                            }
                            throw th;
                        }
                    } else {
                        fileInputStream = new FileInputStream(this.f25009a);
                    }
                    if (r32.skip(this.f25019k + this.f25023o) != this.f25019k + this.f25023o) {
                    }
                } catch (Exception e13) {
                    e10 = e13;
                    Log.d("ExifInterface", "Encountered exception while getting thumbnail", e10);
                    s1.c.b(r32);
                    if (fileDescriptor2 != null) {
                        try {
                            c.a.a(fileDescriptor2);
                        } catch (Exception unused3) {
                            Log.e("ExifInterfaceUtils", "Error closing fd.");
                        }
                    }
                    return null;
                }
                fileDescriptor2 = null;
                r32 = fileInputStream;
            } catch (Exception e14) {
                r32 = 0;
                e10 = e14;
                fileDescriptor2 = null;
            } catch (Throwable th3) {
                th = th3;
                fileDescriptor = 0;
            }
        } catch (Throwable th4) {
            th = th4;
            closeable2 = closeable;
        }
    }

    public final void p(C0199b c0199b) {
        if (f25002t) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + c0199b);
        }
        c0199b.f25033s = ByteOrder.LITTLE_ENDIAN;
        c0199b.a(I.length);
        int readInt = c0199b.readInt() + 8;
        byte[] bArr = J;
        c0199b.a(bArr.length);
        int length = bArr.length + 8;
        while (true) {
            try {
                byte[] bArr2 = new byte[4];
                if (c0199b.read(bArr2) != 4) {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
                int readInt2 = c0199b.readInt();
                int i10 = length + 4 + 4;
                if (Arrays.equals(K, bArr2)) {
                    byte[] bArr3 = new byte[readInt2];
                    if (c0199b.read(bArr3) == readInt2) {
                        this.f25023o = i10;
                        x(bArr3, 0);
                        F(new C0199b(bArr3));
                        return;
                    }
                    throw new IOException("Failed to read given length for given PNG chunk type: " + s1.c.a(bArr2));
                }
                if (readInt2 % 2 == 1) {
                    readInt2++;
                }
                length = i10 + readInt2;
                if (length == readInt) {
                    return;
                }
                if (length > readInt) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                c0199b.a(readInt2);
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void r(C0199b c0199b, HashMap hashMap) {
        d dVar = (d) hashMap.get("JPEGInterchangeFormat");
        d dVar2 = (d) hashMap.get("JPEGInterchangeFormatLength");
        if (dVar == null || dVar2 == null) {
            return;
        }
        int h10 = dVar.h(this.f25015g);
        int h11 = dVar2.h(this.f25015g);
        if (this.f25012d == 7) {
            h10 += this.f25024p;
        }
        if (h10 > 0 && h11 > 0) {
            this.f25016h = true;
            if (this.f25009a == null && this.f25011c == null && this.f25010b == null) {
                byte[] bArr = new byte[h11];
                c0199b.skip(h10);
                c0199b.read(bArr);
                this.f25021m = bArr;
            }
            this.f25019k = h10;
            this.f25020l = h11;
        }
        if (f25002t) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + h10 + ", length: " + h11);
        }
    }

    public final boolean s(HashMap hashMap) {
        d dVar = (d) hashMap.get("ImageLength");
        d dVar2 = (d) hashMap.get("ImageWidth");
        if (dVar == null || dVar2 == null) {
            return false;
        }
        return dVar.h(this.f25015g) <= 512 && dVar2.h(this.f25015g) <= 512;
    }

    public final void t(InputStream inputStream) {
        boolean z10;
        boolean z11 = f25002t;
        if (inputStream == null) {
            throw new NullPointerException("inputstream shouldn't be null");
        }
        for (int i10 = 0; i10 < V.length; i10++) {
            try {
                try {
                    this.f25013e[i10] = new HashMap<>();
                } finally {
                    a();
                    if (z11) {
                        v();
                    }
                }
            } catch (IOException | UnsupportedOperationException e10) {
                if (z11) {
                    Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e10);
                }
                if (!z11) {
                    return;
                }
            }
        }
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
        int i11 = i(bufferedInputStream);
        this.f25012d = i11;
        if (i11 != 4 && i11 != 9 && i11 != 13 && i11 != 14) {
            z10 = true;
            if (z10) {
                C0199b c0199b = new C0199b(bufferedInputStream);
                int i12 = this.f25012d;
                if (i12 == 4) {
                    h(c0199b, 0, 0);
                } else if (i12 == 13) {
                    k(c0199b);
                } else if (i12 == 9) {
                    l(c0199b);
                } else if (i12 == 14) {
                    p(c0199b);
                }
            } else {
                g gVar = new g(bufferedInputStream);
                int i13 = this.f25012d;
                if (i13 == 12) {
                    g(gVar);
                } else if (i13 == 7) {
                    j(gVar);
                } else if (i13 == 10) {
                    n(gVar);
                } else {
                    m(gVar);
                }
                gVar.b(this.f25023o);
                F(gVar);
            }
            a();
            if (!z11) {
                return;
            }
        }
        z10 = false;
        if (z10) {
        }
        a();
        if (!z11) {
        }
    }

    public final void u(C0199b c0199b) {
        ByteOrder w10 = w(c0199b);
        this.f25015g = w10;
        c0199b.f25033s = w10;
        int readUnsignedShort = c0199b.readUnsignedShort();
        int i10 = this.f25012d;
        if (i10 != 7 && i10 != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = c0199b.readInt();
        if (readInt < 8) {
            throw new IOException(android.support.v4.media.a.b("Invalid first Ifd offset: ", readInt));
        }
        int i11 = readInt - 8;
        if (i11 > 0) {
            c0199b.a(i11);
        }
    }

    public final void v() {
        int i10 = 0;
        while (true) {
            HashMap<String, d>[] hashMapArr = this.f25013e;
            if (i10 >= hashMapArr.length) {
                return;
            }
            StringBuilder d10 = o.d("The size of tag group[", i10, "]: ");
            d10.append(hashMapArr[i10].size());
            Log.d("ExifInterface", d10.toString());
            for (Map.Entry<String, d> entry : hashMapArr[i10].entrySet()) {
                d value = entry.getValue();
                Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.i(this.f25015g) + "'");
            }
            i10++;
        }
    }

    public final void x(byte[] bArr, int i10) {
        g gVar = new g(bArr);
        u(gVar);
        y(gVar, i10);
    }

    public final void y(g gVar, int i10) {
        HashMap<String, d>[] hashMapArr;
        short s4;
        HashSet hashSet;
        short s10;
        HashMap<String, d>[] hashMapArr2;
        int i11;
        int[] iArr;
        boolean z10;
        long j10;
        boolean z11;
        int i12;
        e eVar;
        long j11;
        int i13;
        String str;
        boolean z12;
        HashSet hashSet2;
        int readUnsignedShort;
        long j12;
        HashSet hashSet3;
        String str2;
        int i14 = i10;
        Integer valueOf = Integer.valueOf(gVar.f25034t);
        HashSet hashSet4 = this.f25014f;
        hashSet4.add(valueOf);
        short readShort = gVar.readShort();
        String str3 = "ExifInterface";
        boolean z13 = f25002t;
        if (z13) {
            s1.a.a("numberOfDirectoryEntry: ", readShort, "ExifInterface");
        }
        if (readShort <= 0) {
            return;
        }
        short s11 = 0;
        while (true) {
            hashMapArr = this.f25013e;
            if (s11 >= readShort) {
                break;
            }
            int readUnsignedShort2 = gVar.readUnsignedShort();
            int readUnsignedShort3 = gVar.readUnsignedShort();
            int readInt = gVar.readInt();
            long j13 = gVar.f25034t + 4;
            e eVar2 = X[i14].get(Integer.valueOf(readUnsignedShort2));
            if (z13) {
                Object[] objArr = new Object[5];
                objArr[0] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                if (eVar2 != null) {
                    s4 = readShort;
                    str2 = eVar2.f25043b;
                } else {
                    s4 = readShort;
                    str2 = null;
                }
                objArr[2] = str2;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d(str3, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            } else {
                s4 = readShort;
            }
            if (eVar2 == null) {
                if (z13) {
                    s1.a.a("Skip the tag entry since tag number is not defined: ", readUnsignedShort2, str3);
                }
                hashSet = hashSet4;
                s10 = s11;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < S.length) {
                        int i15 = eVar2.f25044c;
                        s10 = s11;
                        if (i15 == 7 || readUnsignedShort3 == 7 || i15 == readUnsignedShort3 || (i12 = eVar2.f25045d) == readUnsignedShort3) {
                            hashSet = hashSet4;
                        } else {
                            hashSet = hashSet4;
                            if (((i15 != 4 && i12 != 4) || readUnsignedShort3 != 3) && (((i15 != 9 && i12 != 9) || readUnsignedShort3 != 8) && ((i15 != 12 && i12 != 12) || readUnsignedShort3 != 11))) {
                                z10 = false;
                                if (!z10) {
                                    if (readUnsignedShort3 == 7) {
                                        hashMapArr2 = hashMapArr;
                                        i11 = readUnsignedShort2;
                                        readUnsignedShort3 = i15;
                                    } else {
                                        hashMapArr2 = hashMapArr;
                                        i11 = readUnsignedShort2;
                                    }
                                    int i16 = readUnsignedShort3;
                                    j10 = readInt * iArr[readUnsignedShort3];
                                    if (j10 < 0 || j10 > 2147483647L) {
                                        if (z13) {
                                            s1.a.a("Skip the tag entry since the number of components is invalid: ", readInt, str3);
                                        }
                                        readUnsignedShort3 = i16;
                                        z11 = false;
                                        if (z11) {
                                            gVar.b(j13);
                                            str = str3;
                                            z12 = z13;
                                            hashSet2 = hashSet;
                                        } else {
                                            if (j10 > 4) {
                                                int readInt2 = gVar.readInt();
                                                j11 = j13;
                                                if (z13) {
                                                    s1.a.a("seek to data offset: ", readInt2, str3);
                                                }
                                                if (this.f25012d == 7) {
                                                    if ("MakerNote".equals(eVar2.f25043b)) {
                                                        this.f25024p = readInt2;
                                                    } else if (i14 == 6 && "ThumbnailImage".equals(eVar2.f25043b)) {
                                                        this.f25025q = readInt2;
                                                        this.f25026r = readInt;
                                                        d e10 = d.e(6, this.f25015g);
                                                        i13 = readInt;
                                                        d b10 = d.b(this.f25025q, this.f25015g);
                                                        eVar = eVar2;
                                                        d b11 = d.b(this.f25026r, this.f25015g);
                                                        hashMapArr2[4].put("Compression", e10);
                                                        hashMapArr2[4].put("JPEGInterchangeFormat", b10);
                                                        hashMapArr2[4].put("JPEGInterchangeFormatLength", b11);
                                                        gVar.b(readInt2);
                                                    }
                                                }
                                                eVar = eVar2;
                                                i13 = readInt;
                                                gVar.b(readInt2);
                                            } else {
                                                eVar = eVar2;
                                                j11 = j13;
                                                i13 = readInt;
                                            }
                                            Integer num = f24995a0.get(Integer.valueOf(i11));
                                            if (z13) {
                                                Log.d(str3, "nextIfdType: " + num + " byteCount: " + j10);
                                            }
                                            if (num != null) {
                                                if (readUnsignedShort3 != 3) {
                                                    if (readUnsignedShort3 == 4) {
                                                        j12 = gVar.readInt() & 4294967295L;
                                                    } else if (readUnsignedShort3 == 8) {
                                                        readUnsignedShort = gVar.readShort();
                                                    } else if (readUnsignedShort3 == 9 || readUnsignedShort3 == 13) {
                                                        readUnsignedShort = gVar.readInt();
                                                    } else {
                                                        j12 = -1;
                                                    }
                                                    if (z13) {
                                                        Log.d(str3, String.format("Offset: %d, tagName: %s", Long.valueOf(j12), eVar.f25043b));
                                                    }
                                                    if (j12 <= 0) {
                                                        hashSet3 = hashSet;
                                                        if (!hashSet3.contains(Integer.valueOf((int) j12))) {
                                                            gVar.b(j12);
                                                            y(gVar, num.intValue());
                                                        } else if (z13) {
                                                            Log.d(str3, "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j12 + ")");
                                                        }
                                                    } else {
                                                        hashSet3 = hashSet;
                                                        if (z13) {
                                                            Log.d(str3, "Skip jump into the IFD since its offset is invalid: " + j12);
                                                        }
                                                    }
                                                    gVar.b(j11);
                                                    str = str3;
                                                    z12 = z13;
                                                    hashSet2 = hashSet3;
                                                } else {
                                                    readUnsignedShort = gVar.readUnsignedShort();
                                                }
                                                j12 = readUnsignedShort;
                                                if (z13) {
                                                }
                                                if (j12 <= 0) {
                                                }
                                                gVar.b(j11);
                                                str = str3;
                                                z12 = z13;
                                                hashSet2 = hashSet3;
                                            } else {
                                                e eVar3 = eVar;
                                                int i17 = gVar.f25034t + this.f25023o;
                                                byte[] bArr = new byte[(int) j10];
                                                gVar.readFully(bArr);
                                                long j14 = i17;
                                                str = str3;
                                                z12 = z13;
                                                long j15 = j11;
                                                hashSet2 = hashSet;
                                                d dVar = new d(j14, bArr, readUnsignedShort3, i13);
                                                hashMapArr2[i10].put(eVar3.f25043b, dVar);
                                                String str4 = eVar3.f25043b;
                                                if ("DNGVersion".equals(str4)) {
                                                    this.f25012d = 3;
                                                }
                                                if ((("Make".equals(str4) || "Model".equals(str4)) && dVar.i(this.f25015g).contains("PENTAX")) || ("Compression".equals(str4) && dVar.h(this.f25015g) == 65535)) {
                                                    this.f25012d = 8;
                                                }
                                                if (gVar.f25034t != j15) {
                                                    gVar.b(j15);
                                                }
                                            }
                                        }
                                        s11 = (short) (s10 + 1);
                                        str3 = str;
                                        z13 = z12;
                                        readShort = s4;
                                        hashSet4 = hashSet2;
                                        i14 = i10;
                                    } else {
                                        z11 = true;
                                        readUnsignedShort3 = i16;
                                        if (z11) {
                                        }
                                        s11 = (short) (s10 + 1);
                                        str3 = str;
                                        z13 = z12;
                                        readShort = s4;
                                        hashSet4 = hashSet2;
                                        i14 = i10;
                                    }
                                } else if (z13) {
                                    Log.d(str3, "Skip the tag entry since data format (" + R[readUnsignedShort3] + ") is unexpected for tag: " + eVar2.f25043b);
                                }
                            }
                        }
                        z10 = true;
                        if (!z10) {
                        }
                    }
                }
                hashSet = hashSet4;
                s10 = s11;
                hashMapArr2 = hashMapArr;
                i11 = readUnsignedShort2;
                if (z13) {
                    s1.a.a("Skip the tag entry since data format is invalid: ", readUnsignedShort3, str3);
                }
                j10 = 0;
                z11 = false;
                if (z11) {
                }
                s11 = (short) (s10 + 1);
                str3 = str;
                z13 = z12;
                readShort = s4;
                hashSet4 = hashSet2;
                i14 = i10;
            }
            hashMapArr2 = hashMapArr;
            i11 = readUnsignedShort2;
            j10 = 0;
            z11 = false;
            if (z11) {
            }
            s11 = (short) (s10 + 1);
            str3 = str;
            z13 = z12;
            readShort = s4;
            hashSet4 = hashSet2;
            i14 = i10;
        }
        HashSet hashSet5 = hashSet4;
        String str5 = str3;
        boolean z14 = z13;
        int readInt3 = gVar.readInt();
        if (z14) {
            Log.d(str5, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
        }
        long j16 = readInt3;
        if (j16 <= 0) {
            if (z14) {
                s1.a.a("Stop reading file since a wrong offset may cause an infinite loop: ", readInt3, str5);
            }
        } else if (hashSet5.contains(Integer.valueOf(readInt3))) {
            if (z14) {
                s1.a.a("Stop reading file since re-reading an IFD may cause an infinite loop: ", readInt3, str5);
            }
        } else {
            gVar.b(j16);
            if (hashMapArr[4].isEmpty()) {
                y(gVar, 4);
            } else if (hashMapArr[5].isEmpty()) {
                y(gVar, 5);
            }
        }
    }

    public final void z(String str) {
        for (int i10 = 0; i10 < V.length; i10++) {
            this.f25013e[i10].remove(str);
        }
    }
}