Live Football Updates v1.0版本的 MD5 值为:95609b5a5bec0a5f5a0b6e8e4d8f1cba

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


package g1;

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 b2.p;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import g1.b;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
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.Pattern;
import java.util.zip.CRC32;
public final class a {
    public static final String[] D;
    public static final int[] E;
    public static final byte[] F;
    public static final d G;
    public static final d[][] H;
    public static final d[] I;
    public static final HashMap<Integer, d>[] J;
    public static final HashMap<String, d>[] K;
    public static final HashSet<String> L;
    public static final HashMap<Integer, Integer> M;
    public static final Charset N;
    public static final byte[] O;
    public static final byte[] P;
    public final FileDescriptor f23163a;
    public final AssetManager.AssetInputStream f23164b;
    public int f23165c;
    public final HashMap<String, c>[] f23166d;
    public final HashSet f23167e;
    public ByteOrder f23168f;
    public boolean f23169g;
    public int f23170h;
    public int i;
    public int f23171j;
    public int f23172k;
    public static final boolean f23149l = Log.isLoggable("ExifInterface", 3);
    public static final List<Integer> f23150m = Arrays.asList(1, 6, 3, 8);
    public static final List<Integer> f23151n = Arrays.asList(2, 7, 4, 5);
    public static final int[] f23152o = {8, 8, 8};
    public static final int[] f23153p = {8};
    public static final byte[] f23154q = {-1, -40, -1};
    public static final byte[] f23155r = {102, 116, 121, 112};
    public static final byte[] f23156s = {109, 105, 102, 49};
    public static final byte[] t = {104, 101, 105, 99};
    public static final byte[] f23157u = {79, 76, 89, 77, 80, 0};
    public static final byte[] f23158v = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] f23159w = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] f23160x = {101, 88, 73, 102};
    public static final byte[] f23161y = {73, 72, 68, 82};
    public static final byte[] f23162z = {73, 69, 78, 68};
    public static final byte[] A = {82, 73, 70, 70};
    public static final byte[] B = {87, 69, 66, 80};
    public static final byte[] C = {69, 88, 73, 70};

    public class C0268a extends MediaDataSource {
        public long f23173a;
        public final f f23174b;

        public C0268a(f fVar) {
            this.f23174b = fVar;
        }

        @Override
        public final void close() throws IOException {
        }

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

        @Override
        public final int readAt(long j4, byte[] bArr, int i, int i10) throws IOException {
            if (i10 == 0) {
                return 0;
            }
            if (j4 < 0) {
                return -1;
            }
            try {
                long j10 = this.f23173a;
                int i11 = (j10 > j4 ? 1 : (j10 == j4 ? 0 : -1));
                f fVar = this.f23174b;
                if (i11 != 0) {
                    if (j10 >= 0 && j4 >= j10 + fVar.available()) {
                        return -1;
                    }
                    fVar.b(j4);
                    this.f23173a = j4;
                }
                if (i10 > fVar.available()) {
                    i10 = fVar.available();
                }
                int read = fVar.read(bArr, i, i10);
                if (read >= 0) {
                    this.f23173a += read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.f23173a = -1L;
            return -1;
        }
    }

    public static class b extends InputStream implements DataInput {
        public static final ByteOrder f23175e = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder f23176f = ByteOrder.BIG_ENDIAN;
        public final DataInputStream f23177a;
        public ByteOrder f23178b;
        public int f23179c;
        public byte[] f23180d;

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

        public final void a(int i) throws IOException {
            int i10 = 0;
            while (i10 < i) {
                DataInputStream dataInputStream = this.f23177a;
                int i11 = i - i10;
                int skip = (int) dataInputStream.skip(i11);
                if (skip <= 0) {
                    if (this.f23180d == null) {
                        this.f23180d = new byte[8192];
                    }
                    skip = dataInputStream.read(this.f23180d, 0, Math.min(8192, i11));
                    if (skip == -1) {
                        throw new EOFException(a0.f.h("Reached EOF while skipping ", i, " bytes."));
                    }
                }
                i10 += skip;
            }
            this.f23179c += i10;
        }

        @Override
        public final int available() throws IOException {
            return this.f23177a.available();
        }

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

        @Override
        public final int read() throws IOException {
            this.f23179c++;
            return this.f23177a.read();
        }

        @Override
        public final boolean readBoolean() throws IOException {
            this.f23179c++;
            return this.f23177a.readBoolean();
        }

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

        @Override
        public final char readChar() throws IOException {
            this.f23179c += 2;
            return this.f23177a.readChar();
        }

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

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

        @Override
        public final void readFully(byte[] bArr, int i, int i10) throws IOException {
            this.f23179c += i10;
            this.f23177a.readFully(bArr, i, i10);
        }

        @Override
        public final int readInt() throws IOException {
            this.f23179c += 4;
            DataInputStream dataInputStream = this.f23177a;
            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.f23178b;
                if (byteOrder == f23175e) {
                    return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                }
                if (byteOrder == f23176f) {
                    return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                }
                throw new IOException("Invalid byte order: " + this.f23178b);
            }
            throw new EOFException();
        }

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

        @Override
        public final long readLong() throws IOException {
            this.f23179c += 8;
            DataInputStream dataInputStream = this.f23177a;
            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.f23178b;
                if (byteOrder == f23175e) {
                    return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                }
                if (byteOrder == f23176f) {
                    return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                }
                throw new IOException("Invalid byte order: " + this.f23178b);
            }
            throw new EOFException();
        }

        @Override
        public final short readShort() throws IOException {
            this.f23179c += 2;
            DataInputStream dataInputStream = this.f23177a;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) >= 0) {
                ByteOrder byteOrder = this.f23178b;
                if (byteOrder == f23175e) {
                    return (short) ((read2 << 8) + read);
                }
                if (byteOrder == f23176f) {
                    return (short) ((read << 8) + read2);
                }
                throw new IOException("Invalid byte order: " + this.f23178b);
            }
            throw new EOFException();
        }

        @Override
        public final String readUTF() throws IOException {
            this.f23179c += 2;
            return this.f23177a.readUTF();
        }

        @Override
        public final int readUnsignedByte() throws IOException {
            this.f23179c++;
            return this.f23177a.readUnsignedByte();
        }

        @Override
        public final int readUnsignedShort() throws IOException {
            this.f23179c += 2;
            DataInputStream dataInputStream = this.f23177a;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) >= 0) {
                ByteOrder byteOrder = this.f23178b;
                if (byteOrder == f23175e) {
                    return (read2 << 8) + read;
                }
                if (byteOrder == f23176f) {
                    return (read << 8) + read2;
                }
                throw new IOException("Invalid byte order: " + this.f23178b);
            }
            throw new EOFException();
        }

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

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

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

        public b(InputStream inputStream, ByteOrder byteOrder) throws IOException {
            this.f23178b = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f23177a = dataInputStream;
            dataInputStream.mark(0);
            this.f23179c = 0;
            this.f23178b = byteOrder;
        }

        @Override
        public final int read(byte[] bArr, int i, int i10) throws IOException {
            int read = this.f23177a.read(bArr, i, i10);
            this.f23179c += read;
            return read;
        }

        @Override
        public final void readFully(byte[] bArr) throws IOException {
            this.f23179c += bArr.length;
            this.f23177a.readFully(bArr);
        }
    }

    public static class c {
        public final int f23181a;
        public final int f23182b;
        public final long f23183c;
        public final byte[] f23184d;

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

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

        public static c b(long j4, ByteOrder byteOrder) {
            long[] jArr = {j4};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[4] * 1]);
            wrap.order(byteOrder);
            wrap.putInt((int) jArr[0]);
            return new c(wrap.array(), 4, 1);
        }

        public static c c(e eVar, ByteOrder byteOrder) {
            e[] eVarArr = {eVar};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[5] * 1]);
            wrap.order(byteOrder);
            e eVar2 = eVarArr[0];
            wrap.putInt((int) eVar2.f23189a);
            wrap.putInt((int) eVar2.f23190b);
            return new c(wrap.array(), 5, 1);
        }

        public static c d(int i, ByteOrder byteOrder) {
            int[] iArr = {i};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[3] * 1]);
            wrap.order(byteOrder);
            wrap.putShort((short) iArr[0]);
            return new c(wrap.array(), 3, 1);
        }

        public final double e(ByteOrder byteOrder) {
            Serializable h10 = h(byteOrder);
            if (h10 != null) {
                if (h10 instanceof String) {
                    return Double.parseDouble((String) h10);
                }
                if (h10 instanceof long[]) {
                    long[] jArr = (long[]) h10;
                    if (jArr.length == 1) {
                        return jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (h10 instanceof int[]) {
                    int[] iArr = (int[]) h10;
                    if (iArr.length == 1) {
                        return iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (h10 instanceof double[]) {
                    double[] dArr = (double[]) h10;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (h10 instanceof e[]) {
                    e[] eVarArr = (e[]) h10;
                    if (eVarArr.length == 1) {
                        e eVar = eVarArr[0];
                        return eVar.f23189a / eVar.f23190b;
                    }
                    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 f(ByteOrder byteOrder) {
            Serializable h10 = h(byteOrder);
            if (h10 != null) {
                if (h10 instanceof String) {
                    return Integer.parseInt((String) h10);
                }
                if (h10 instanceof long[]) {
                    long[] jArr = (long[]) h10;
                    if (jArr.length == 1) {
                        return (int) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (h10 instanceof int[]) {
                    int[] iArr = (int[]) h10;
                    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 g(ByteOrder byteOrder) {
            Serializable h10 = h(byteOrder);
            if (h10 == null) {
                return null;
            }
            if (h10 instanceof String) {
                return (String) h10;
            }
            StringBuilder sb = new StringBuilder();
            int i = 0;
            if (h10 instanceof long[]) {
                long[] jArr = (long[]) h10;
                while (i < jArr.length) {
                    sb.append(jArr[i]);
                    i++;
                    if (i != jArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (h10 instanceof int[]) {
                int[] iArr = (int[]) h10;
                while (i < iArr.length) {
                    sb.append(iArr[i]);
                    i++;
                    if (i != iArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (h10 instanceof double[]) {
                double[] dArr = (double[]) h10;
                while (i < dArr.length) {
                    sb.append(dArr[i]);
                    i++;
                    if (i != dArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            } else if (!(h10 instanceof e[])) {
                return null;
            } else {
                e[] eVarArr = (e[]) h10;
                while (i < eVarArr.length) {
                    sb.append(eVarArr[i].f23189a);
                    sb.append('/');
                    sb.append(eVarArr[i].f23190b);
                    i++;
                    if (i != eVarArr.length) {
                        sb.append(",");
                    }
                }
                return sb.toString();
            }
        }

        public final Serializable h(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b10;
            byte[] bArr;
            byte[] bArr2 = this.f23184d;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(bArr2);
                    try {
                        bVar.f23178b = byteOrder;
                        int i = this.f23181a;
                        boolean z10 = true;
                        int i10 = 0;
                        int i11 = this.f23182b;
                        switch (i) {
                            case 1:
                            case 6:
                                if (bArr2.length == 1 && (b10 = bArr2[0]) >= 0 && b10 <= 1) {
                                    String str = new String(new char[]{(char) (b10 + 48)});
                                    try {
                                        bVar.close();
                                    } catch (IOException e10) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                    }
                                    return str;
                                }
                                String str2 = new String(bArr2, a.N);
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (i11 >= a.F.length) {
                                    int i12 = 0;
                                    while (true) {
                                        bArr = a.F;
                                        if (i12 < bArr.length) {
                                            if (bArr2[i12] != bArr[i12]) {
                                                z10 = false;
                                            } else {
                                                i12++;
                                            }
                                        }
                                    }
                                    if (z10) {
                                        i10 = bArr.length;
                                    }
                                }
                                StringBuilder sb = new StringBuilder();
                                while (i10 < i11) {
                                    byte b11 = bArr2[i10];
                                    if (b11 != 0) {
                                        if (b11 >= 32) {
                                            sb.append((char) b11);
                                        } else {
                                            sb.append('?');
                                        }
                                        i10++;
                                    } else {
                                        String sb2 = sb.toString();
                                        bVar.close();
                                        return sb2;
                                    }
                                }
                                String sb22 = sb.toString();
                                bVar.close();
                                return sb22;
                            case 3:
                                ?? r15 = new int[i11];
                                while (i10 < i11) {
                                    r15[i10] = bVar.readUnsignedShort();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return r15;
                            case 4:
                                ?? r152 = new long[i11];
                                while (i10 < i11) {
                                    r152[i10] = bVar.readInt() & 4294967295L;
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e13) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                                }
                                return r152;
                            case 5:
                                ?? r153 = new e[i11];
                                while (i10 < i11) {
                                    r153[i10] = new e(bVar.readInt() & 4294967295L, bVar.readInt() & 4294967295L);
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e14) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                                }
                                return r153;
                            case 8:
                                ?? r154 = new int[i11];
                                while (i10 < i11) {
                                    r154[i10] = bVar.readShort();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e15) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                                }
                                return r154;
                            case 9:
                                ?? r155 = new int[i11];
                                while (i10 < i11) {
                                    r155[i10] = bVar.readInt();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e16) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                                }
                                return r155;
                            case 10:
                                ?? r156 = new e[i11];
                                while (i10 < i11) {
                                    r156[i10] = new e(bVar.readInt(), bVar.readInt());
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e17) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e17);
                                }
                                return r156;
                            case 11:
                                ?? r157 = new double[i11];
                                while (i10 < i11) {
                                    r157[i10] = bVar.readFloat();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e18) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e18);
                                }
                                return r157;
                            case 12:
                                ?? r158 = new double[i11];
                                while (i10 < i11) {
                                    r158[i10] = bVar.readDouble();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e19) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e19);
                                }
                                return r158;
                            default:
                                try {
                                    bVar.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 (bVar != null) {
                            try {
                                bVar.close();
                            } catch (IOException e22) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e22);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    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;
                bVar = null;
            } catch (Throwable th3) {
                th = th3;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

        public final String toString() {
            StringBuilder sb = new StringBuilder("(");
            sb.append(a.D[this.f23181a]);
            sb.append(", data length:");
            return he.b.a(sb, this.f23184d.length, ")");
        }

        public c(long j4, byte[] bArr, int i, int i10) {
            this.f23181a = i;
            this.f23182b = i10;
            this.f23183c = j4;
            this.f23184d = bArr;
        }
    }

    public static class e {
        public final long f23189a;
        public final long f23190b;

        public e(long j4, long j10) {
            if (j10 == 0) {
                this.f23189a = 0L;
                this.f23190b = 1L;
                return;
            }
            this.f23189a = j4;
            this.f23190b = j10;
        }

        public final String toString() {
            return this.f23189a + "/" + this.f23190b;
        }
    }

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

    public a(InputStream inputStream) throws IOException {
        boolean z10;
        d[][] dVarArr = H;
        this.f23166d = new HashMap[dVarArr.length];
        this.f23167e = new HashSet(dVarArr.length);
        this.f23168f = ByteOrder.BIG_ENDIAN;
        if (inputStream != null) {
            boolean z11 = inputStream instanceof AssetManager.AssetInputStream;
            boolean z12 = true;
            boolean z13 = f23149l;
            if (z11) {
                this.f23164b = (AssetManager.AssetInputStream) inputStream;
                this.f23163a = null;
            } else {
                if (inputStream instanceof FileInputStream) {
                    FileInputStream fileInputStream = (FileInputStream) inputStream;
                    try {
                        b.a.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                        z10 = true;
                    } catch (Exception unused) {
                        if (z13) {
                            Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                        }
                        z10 = false;
                    }
                    if (z10) {
                        this.f23164b = null;
                        this.f23163a = fileInputStream.getFD();
                    }
                }
                this.f23164b = null;
                this.f23163a = null;
            }
            for (int i = 0; i < dVarArr.length; i++) {
                try {
                    try {
                        this.f23166d[i] = new HashMap<>();
                    } finally {
                        a();
                        if (z13) {
                            p();
                        }
                    }
                } catch (IOException | UnsupportedOperationException e10) {
                    if (z13) {
                        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 (!z13) {
                        return;
                    }
                }
            }
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            int f10 = f(bufferedInputStream);
            this.f23165c = f10;
            if ((f10 == 4 || f10 == 9 || f10 == 13 || f10 == 14) ? false : z12) {
                f fVar = new f(bufferedInputStream);
                int i10 = this.f23165c;
                if (i10 == 12) {
                    d(fVar);
                } else if (i10 == 7) {
                    g(fVar);
                } else if (i10 == 10) {
                    k(fVar);
                } else {
                    j(fVar);
                }
                fVar.b(this.f23170h);
                u(fVar);
            } else {
                b bVar = new b(bufferedInputStream);
                int i11 = this.f23165c;
                if (i11 == 4) {
                    e(bVar, 0, 0);
                } else if (i11 == 13) {
                    h(bVar);
                } else if (i11 == 9) {
                    i(bVar);
                } else if (i11 == 14) {
                    l(bVar);
                }
            }
            a();
            if (!z13) {
                return;
            }
            return;
        }
        throw new NullPointerException("inputStream cannot be null");
    }

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

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

    public final String b(String str) {
        c c10 = c(str);
        if (c10 != null) {
            if (!L.contains(str)) {
                return c10.g(this.f23168f);
            }
            if (str.equals("GPSTimeStamp")) {
                int i = c10.f23181a;
                if (i != 5 && i != 10) {
                    Log.w("ExifInterface", "GPS Timestamp format is not rational. format=" + i);
                    return null;
                }
                e[] eVarArr = (e[]) c10.h(this.f23168f);
                if (eVarArr != null && eVarArr.length == 3) {
                    e eVar = eVarArr[0];
                    e eVar2 = eVarArr[1];
                    e eVar3 = eVarArr[2];
                    return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVar.f23189a) / ((float) eVar.f23190b))), Integer.valueOf((int) (((float) eVar2.f23189a) / ((float) eVar2.f23190b))), Integer.valueOf((int) (((float) eVar3.f23189a) / ((float) eVar3.f23190b))));
                }
                Log.w("ExifInterface", "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr));
                return null;
            }
            try {
                return Double.toString(c10.e(this.f23168f));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

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

    public final void d(f fVar) throws IOException {
        String str;
        String str2;
        String str3;
        int i;
        if (Build.VERSION.SDK_INT >= 28) {
            MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
            try {
                try {
                    b.C0269b.a(mediaMetadataRetriever, new C0268a(fVar));
                    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, c>[] hashMapArr = this.f23166d;
                    if (str != null) {
                        hashMapArr[0].put("ImageWidth", c.d(Integer.parseInt(str), this.f23168f));
                    }
                    if (str2 != null) {
                        hashMapArr[0].put("ImageLength", c.d(Integer.parseInt(str2), this.f23168f));
                    }
                    if (str3 != null) {
                        int parseInt = Integer.parseInt(str3);
                        if (parseInt != 90) {
                            if (parseInt != 180) {
                                if (parseInt != 270) {
                                    i = 1;
                                } else {
                                    i = 8;
                                }
                            } else {
                                i = 3;
                            }
                        } else {
                            i = 6;
                        }
                        hashMapArr[0].put("Orientation", c.d(i, this.f23168f));
                    }
                    if (extractMetadata != null && extractMetadata2 != null) {
                        int parseInt2 = Integer.parseInt(extractMetadata);
                        int parseInt3 = Integer.parseInt(extractMetadata2);
                        if (parseInt3 > 6) {
                            fVar.b(parseInt2);
                            byte[] bArr = new byte[6];
                            if (fVar.read(bArr) == 6) {
                                int i10 = parseInt2 + 6;
                                int i11 = parseInt3 - 6;
                                if (Arrays.equals(bArr, O)) {
                                    byte[] bArr2 = new byte[i11];
                                    if (fVar.read(bArr2) == i11) {
                                        this.f23170h = i10;
                                        r(bArr2, 0);
                                    } else {
                                        throw new IOException("Can't read exif");
                                    }
                                } else {
                                    throw new IOException("Invalid identifier");
                                }
                            } else {
                                throw new IOException("Can't read identifier");
                            }
                        } else {
                            throw new IOException("Invalid exif length");
                        }
                    }
                    if (f23149l) {
                        Log.d("ExifInterface", "Heif meta: " + str + "x" + str2 + ", rotation " + str3);
                    }
                    return;
                } catch (RuntimeException unused) {
                    throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported.");
                }
            } finally {
                mediaMetadataRetriever.release();
            }
        }
        throw new UnsupportedOperationException("Reading EXIF from HEIF files is supported from SDK 28 and above");
    }

    public final void e(b bVar, int i, int i10) throws IOException {
        byte readByte;
        byte readByte2;
        boolean z10;
        boolean z11;
        String str;
        String str2;
        boolean z12 = f23149l;
        if (z12) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.f23178b = ByteOrder.BIG_ENDIAN;
        byte b10 = -1;
        if (bVar.readByte() == -1) {
            if (bVar.readByte() == -40) {
                int i11 = 2;
                int i12 = 2;
                while (true) {
                    if (bVar.readByte() == b10) {
                        int i13 = i12 + 1;
                        byte readByte3 = bVar.readByte();
                        if (z12) {
                            Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                        }
                        int i14 = i13 + 1;
                        if (readByte3 != -39 && readByte3 != -38) {
                            int readUnsignedShort = bVar.readUnsignedShort() - i11;
                            int i15 = i14 + i11;
                            if (z12) {
                                Log.d("ExifInterface", "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")");
                            }
                            if (readUnsignedShort >= 0) {
                                HashMap<String, c>[] hashMapArr = this.f23166d;
                                if (readByte3 != -31) {
                                    if (readByte3 != -2) {
                                        switch (readByte3) {
                                            default:
                                                switch (readByte3) {
                                                    default:
                                                        switch (readByte3) {
                                                            default:
                                                                switch (readByte3) {
                                                                }
                                                            case -55:
                                                            case -54:
                                                            case -53:
                                                                bVar.a(1);
                                                                HashMap<String, c> hashMap = hashMapArr[i10];
                                                                if (i10 != 4) {
                                                                    str = "ImageLength";
                                                                } else {
                                                                    str = "ThumbnailImageLength";
                                                                }
                                                                hashMap.put(str, c.b(bVar.readUnsignedShort(), this.f23168f));
                                                                HashMap<String, c> hashMap2 = hashMapArr[i10];
                                                                if (i10 != 4) {
                                                                    str2 = "ImageWidth";
                                                                } else {
                                                                    str2 = "ThumbnailImageWidth";
                                                                }
                                                                hashMap2.put(str2, c.b(bVar.readUnsignedShort(), this.f23168f));
                                                                readUnsignedShort -= 5;
                                                                break;
                                                        }
                                                    case -59:
                                                    case -58:
                                                    case -57:
                                                        break;
                                                }
                                            case -64:
                                            case -63:
                                            case -62:
                                            case -61:
                                                break;
                                        }
                                        if (readUnsignedShort < 0) {
                                            bVar.a(readUnsignedShort);
                                            i12 = i15 + readUnsignedShort;
                                            i11 = 2;
                                            b10 = -1;
                                        } else {
                                            throw new IOException("Invalid length");
                                        }
                                    } else {
                                        byte[] bArr = new byte[readUnsignedShort];
                                        if (bVar.read(bArr) == readUnsignedShort) {
                                            if (b("UserComment") == null) {
                                                hashMapArr[1].put("UserComment", c.a(new String(bArr, N)));
                                            }
                                        } else {
                                            throw new IOException("Invalid exif");
                                        }
                                    }
                                } else {
                                    byte[] bArr2 = new byte[readUnsignedShort];
                                    bVar.readFully(bArr2);
                                    int i16 = i15 + readUnsignedShort;
                                    byte[] bArr3 = O;
                                    if (bArr3 != null && readUnsignedShort >= bArr3.length) {
                                        for (int i17 = 0; i17 < bArr3.length; i17++) {
                                            if (bArr2[i17] == bArr3[i17]) {
                                            }
                                        }
                                        z10 = true;
                                        if (!z10) {
                                            byte[] copyOfRange = Arrays.copyOfRange(bArr2, bArr3.length, readUnsignedShort);
                                            this.f23170h = i + i15 + bArr3.length;
                                            r(copyOfRange, i10);
                                            u(new b(copyOfRange));
                                        } else {
                                            byte[] bArr4 = P;
                                            if (bArr4 != null && readUnsignedShort >= bArr4.length) {
                                                for (int i18 = 0; i18 < bArr4.length; i18++) {
                                                    if (bArr2[i18] == bArr4[i18]) {
                                                    }
                                                }
                                                z11 = true;
                                                if (z11) {
                                                    int length = bArr4.length + i15;
                                                    byte[] copyOfRange2 = Arrays.copyOfRange(bArr2, bArr4.length, readUnsignedShort);
                                                    if (b("Xmp") == null) {
                                                        hashMapArr[0].put("Xmp", new c(length, copyOfRange2, 1, copyOfRange2.length));
                                                    }
                                                }
                                            }
                                            z11 = false;
                                            if (z11) {
                                            }
                                        }
                                        i15 = i16;
                                    }
                                    z10 = false;
                                    if (!z10) {
                                    }
                                    i15 = i16;
                                }
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 0) {
                                }
                            } else {
                                throw new IOException("Invalid length");
                            }
                        }
                    } else {
                        throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
                    }
                }
            } else {
                throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
            }
        } else {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
    }

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

    public final void g(f fVar) throws IOException {
        int i;
        int i10;
        j(fVar);
        HashMap<String, c>[] hashMapArr = this.f23166d;
        c cVar = hashMapArr[1].get("MakerNote");
        if (cVar != null) {
            f fVar2 = new f(cVar.f23184d);
            fVar2.f23178b = this.f23168f;
            byte[] bArr = f23157u;
            byte[] bArr2 = new byte[bArr.length];
            fVar2.readFully(bArr2);
            fVar2.b(0L);
            byte[] bArr3 = f23158v;
            byte[] bArr4 = new byte[bArr3.length];
            fVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                fVar2.b(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                fVar2.b(12L);
            }
            s(fVar2, 6);
            c cVar2 = hashMapArr[7].get("PreviewImageStart");
            c cVar3 = hashMapArr[7].get("PreviewImageLength");
            if (cVar2 != null && cVar3 != null) {
                hashMapArr[5].put("JPEGInterchangeFormat", cVar2);
                hashMapArr[5].put("JPEGInterchangeFormatLength", cVar3);
            }
            c cVar4 = hashMapArr[8].get("AspectFrame");
            if (cVar4 != null) {
                int[] iArr = (int[]) cVar4.h(this.f23168f);
                if (iArr != null && iArr.length == 4) {
                    int i11 = iArr[2];
                    int i12 = iArr[0];
                    if (i11 > i12 && (i = iArr[3]) > (i10 = iArr[1])) {
                        int i13 = (i11 - i12) + 1;
                        int i14 = (i - i10) + 1;
                        if (i13 < i14) {
                            int i15 = i13 + i14;
                            i14 = i15 - i14;
                            i13 = i15 - i14;
                        }
                        c d10 = c.d(i13, this.f23168f);
                        c d11 = c.d(i14, this.f23168f);
                        hashMapArr[0].put("ImageWidth", d10);
                        hashMapArr[0].put("ImageLength", d11);
                        return;
                    }
                    return;
                }
                Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
            }
        }
    }

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

    public final void i(b bVar) throws IOException {
        boolean z10 = f23149l;
        if (z10) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + bVar);
        }
        bVar.a(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        byte[] bArr3 = new byte[4];
        bVar.read(bArr);
        bVar.read(bArr2);
        bVar.read(bArr3);
        int i = ByteBuffer.wrap(bArr).getInt();
        int i10 = ByteBuffer.wrap(bArr2).getInt();
        int i11 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i10];
        bVar.a(i - bVar.f23179c);
        bVar.read(bArr4);
        e(new b(bArr4), i, 5);
        bVar.a(i11 - bVar.f23179c);
        bVar.f23178b = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (z10) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i12 = 0; i12 < readInt; i12++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == G.f23185a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c d10 = c.d(readShort, this.f23168f);
                c d11 = c.d(readShort2, this.f23168f);
                HashMap<String, c>[] hashMapArr = this.f23166d;
                hashMapArr[0].put("ImageLength", d10);
                hashMapArr[0].put("ImageWidth", d11);
                if (z10) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.a(readUnsignedShort2);
        }
    }

    public final void j(f fVar) throws IOException {
        o(fVar);
        s(fVar, 0);
        w(fVar, 0);
        w(fVar, 5);
        w(fVar, 4);
        x();
        if (this.f23165c == 8) {
            HashMap<String, c>[] hashMapArr = this.f23166d;
            c cVar = hashMapArr[1].get("MakerNote");
            if (cVar != null) {
                f fVar2 = new f(cVar.f23184d);
                fVar2.f23178b = this.f23168f;
                fVar2.a(6);
                s(fVar2, 9);
                c cVar2 = hashMapArr[9].get("ColorSpace");
                if (cVar2 != null) {
                    hashMapArr[1].put("ColorSpace", cVar2);
                }
            }
        }
    }

    public final void k(f fVar) throws IOException {
        if (f23149l) {
            Log.d("ExifInterface", "getRw2Attributes starting with: " + fVar);
        }
        j(fVar);
        HashMap<String, c>[] hashMapArr = this.f23166d;
        c cVar = hashMapArr[0].get("JpgFromRaw");
        if (cVar != null) {
            e(new b(cVar.f23184d), (int) cVar.f23183c, 5);
        }
        c cVar2 = hashMapArr[0].get("ISO");
        c cVar3 = hashMapArr[1].get("PhotographicSensitivity");
        if (cVar2 != null && cVar3 == null) {
            hashMapArr[1].put("PhotographicSensitivity", cVar2);
        }
    }

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

    public final void m(b bVar, HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar != null && cVar2 != null) {
            int f10 = cVar.f(this.f23168f);
            int f11 = cVar2.f(this.f23168f);
            if (this.f23165c == 7) {
                f10 += this.i;
            }
            if (f10 > 0 && f11 > 0 && this.f23164b == null && this.f23163a == null) {
                bVar.skip(f10);
                bVar.read(new byte[f11]);
            }
            if (f23149l) {
                Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + f10 + ", length: " + f11);
            }
        }
    }

    public final boolean n(HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("ImageLength");
        c cVar2 = (c) hashMap.get("ImageWidth");
        if (cVar != null && cVar2 != null) {
            int f10 = cVar.f(this.f23168f);
            int f11 = cVar2.f(this.f23168f);
            if (f10 <= 512 && f11 <= 512) {
                return true;
            }
            return false;
        }
        return false;
    }

    public final void o(b bVar) throws IOException {
        ByteOrder q10 = q(bVar);
        this.f23168f = q10;
        bVar.f23178b = q10;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i = this.f23165c;
        if (i != 7 && i != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = bVar.readInt();
        if (readInt >= 8) {
            int i10 = readInt - 8;
            if (i10 > 0) {
                bVar.a(i10);
                return;
            }
            return;
        }
        throw new IOException(p.g("Invalid first Ifd offset: ", readInt));
    }

    public final void p() {
        int i = 0;
        while (true) {
            HashMap<String, c>[] hashMapArr = this.f23166d;
            if (i < hashMapArr.length) {
                StringBuilder e10 = ak.f.e("The size of tag group[", i, "]: ");
                e10.append(hashMapArr[i].size());
                Log.d("ExifInterface", e10.toString());
                for (Map.Entry<String, c> entry : hashMapArr[i].entrySet()) {
                    c value = entry.getValue();
                    Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.g(this.f23168f) + "'");
                }
                i++;
            } else {
                return;
            }
        }
    }

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

    public final void s(f fVar, int i) throws IOException {
        HashMap<String, c>[] hashMapArr;
        String str;
        short s10;
        short s11;
        HashSet hashSet;
        int[] iArr;
        boolean z10;
        long j4;
        boolean z11;
        int i10;
        d dVar;
        HashSet hashSet2;
        int i11;
        long j10;
        int i12;
        HashSet hashSet3;
        String str2;
        boolean z12;
        int readUnsignedShort;
        long j11;
        String str3;
        Integer valueOf = Integer.valueOf(fVar.f23179c);
        HashSet hashSet4 = this.f23167e;
        hashSet4.add(valueOf);
        short readShort = fVar.readShort();
        String str4 = "ExifInterface";
        boolean z13 = f23149l;
        if (z13) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (readShort <= 0) {
            return;
        }
        short s12 = 0;
        while (true) {
            hashMapArr = this.f23166d;
            if (s12 >= readShort) {
                break;
            }
            int readUnsignedShort2 = fVar.readUnsignedShort();
            int readUnsignedShort3 = fVar.readUnsignedShort();
            int readInt = fVar.readInt();
            long j12 = fVar.f23179c + 4;
            d dVar2 = J[i].get(Integer.valueOf(readUnsignedShort2));
            if (z13) {
                Object[] objArr = new Object[5];
                objArr[0] = Integer.valueOf(i);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                if (dVar2 != null) {
                    str3 = dVar2.f23186b;
                } else {
                    str3 = null;
                }
                objArr[2] = str3;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d(str4, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            }
            if (dVar2 == null) {
                if (z13) {
                    Log.d(str4, "Skip the tag entry since tag number is not defined: " + readUnsignedShort2);
                }
                s10 = readShort;
                s11 = s12;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < E.length) {
                        int i13 = dVar2.f23187c;
                        s10 = readShort;
                        if (i13 != 7 && readUnsignedShort3 != 7 && i13 != readUnsignedShort3 && (i10 = dVar2.f23188d) != readUnsignedShort3) {
                            s11 = s12;
                            if (((i13 != 4 && i10 != 4) || readUnsignedShort3 != 3) && (((i13 != 9 && i10 != 9) || readUnsignedShort3 != 8) && ((i13 != 12 && i10 != 12) || readUnsignedShort3 != 11))) {
                                z10 = false;
                                if (z10) {
                                    if (z13) {
                                        Log.d(str4, "Skip the tag entry since data format (" + D[readUnsignedShort3] + ") is unexpected for tag: " + dVar2.f23186b);
                                    }
                                } else {
                                    hashSet = hashSet4;
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i13;
                                    }
                                    int i14 = readUnsignedShort3;
                                    j4 = readInt * iArr[readUnsignedShort3];
                                    if (j4 >= 0 && j4 <= 2147483647L) {
                                        readUnsignedShort3 = i14;
                                        z11 = true;
                                        if (z11) {
                                        }
                                        s12 = (short) (s11 + 1);
                                        hashSet4 = hashSet3;
                                        str4 = str2;
                                        z13 = z12;
                                        readShort = s10;
                                    } else {
                                        if (z13) {
                                            Log.d(str4, "Skip the tag entry since the number of components is invalid: " + readInt);
                                        }
                                        readUnsignedShort3 = i14;
                                        z11 = false;
                                        if (z11) {
                                            fVar.b(j12);
                                            str2 = str4;
                                            z12 = z13;
                                            hashSet3 = hashSet;
                                        } else {
                                            if (j4 > 4) {
                                                int readInt2 = fVar.readInt();
                                                j10 = j12;
                                                if (z13) {
                                                    Log.d(str4, "seek to data offset: " + readInt2);
                                                }
                                                if (this.f23165c == 7) {
                                                    if ("MakerNote".equals(dVar2.f23186b)) {
                                                        this.i = readInt2;
                                                    } else if (i == 6 && "ThumbnailImage".equals(dVar2.f23186b)) {
                                                        this.f23171j = readInt2;
                                                        this.f23172k = readInt;
                                                        c d10 = c.d(6, this.f23168f);
                                                        dVar = dVar2;
                                                        hashSet2 = hashSet;
                                                        c b10 = c.b(this.f23171j, this.f23168f);
                                                        i11 = readUnsignedShort3;
                                                        i12 = readInt;
                                                        c b11 = c.b(this.f23172k, this.f23168f);
                                                        hashMapArr[4].put("Compression", d10);
                                                        hashMapArr[4].put("JPEGInterchangeFormat", b10);
                                                        hashMapArr[4].put("JPEGInterchangeFormatLength", b11);
                                                        fVar.b(readInt2);
                                                    }
                                                }
                                                dVar = dVar2;
                                                hashSet2 = hashSet;
                                                i11 = readUnsignedShort3;
                                                i12 = readInt;
                                                fVar.b(readInt2);
                                            } else {
                                                dVar = dVar2;
                                                hashSet2 = hashSet;
                                                i11 = readUnsignedShort3;
                                                j10 = j12;
                                                i12 = readInt;
                                            }
                                            Integer num = M.get(Integer.valueOf(readUnsignedShort2));
                                            if (z13) {
                                                Log.d(str4, "nextIfdType: " + num + " byteCount: " + j4);
                                            }
                                            if (num != null) {
                                                int i15 = i11;
                                                if (i15 != 3) {
                                                    if (i15 != 4) {
                                                        if (i15 != 8) {
                                                            if (i15 != 9 && i15 != 13) {
                                                                j11 = -1;
                                                            } else {
                                                                readUnsignedShort = fVar.readInt();
                                                            }
                                                        } else {
                                                            readUnsignedShort = fVar.readShort();
                                                        }
                                                    } else {
                                                        j11 = fVar.readInt() & 4294967295L;
                                                    }
                                                    if (z13) {
                                                        Log.d(str4, String.format("Offset: %d, tagName: %s", Long.valueOf(j11), dVar.f23186b));
                                                    }
                                                    if (j11 <= 0) {
                                                        hashSet3 = hashSet2;
                                                        if (!hashSet3.contains(Integer.valueOf((int) j11))) {
                                                            fVar.b(j11);
                                                            s(fVar, num.intValue());
                                                        } else if (z13) {
                                                            Log.d(str4, "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j11 + ")");
                                                        }
                                                    } else {
                                                        hashSet3 = hashSet2;
                                                        if (z13) {
                                                            Log.d(str4, "Skip jump into the IFD since its offset is invalid: " + j11);
                                                        }
                                                    }
                                                    fVar.b(j10);
                                                    str2 = str4;
                                                    z12 = z13;
                                                } else {
                                                    readUnsignedShort = fVar.readUnsignedShort();
                                                }
                                                j11 = readUnsignedShort;
                                                if (z13) {
                                                }
                                                if (j11 <= 0) {
                                                }
                                                fVar.b(j10);
                                                str2 = str4;
                                                z12 = z13;
                                            } else {
                                                d dVar3 = dVar;
                                                long j13 = j10;
                                                hashSet3 = hashSet2;
                                                int i16 = fVar.f23179c + this.f23170h;
                                                byte[] bArr = new byte[(int) j4];
                                                fVar.readFully(bArr);
                                                str2 = str4;
                                                z12 = z13;
                                                c cVar = new c(i16, bArr, i11, i12);
                                                hashMapArr[i].put(dVar3.f23186b, cVar);
                                                String str5 = dVar3.f23186b;
                                                if ("DNGVersion".equals(str5)) {
                                                    this.f23165c = 3;
                                                }
                                                if ((("Make".equals(str5) || "Model".equals(str5)) && cVar.g(this.f23168f).contains("PENTAX")) || ("Compression".equals(str5) && cVar.f(this.f23168f) == 65535)) {
                                                    this.f23165c = 8;
                                                }
                                                if (fVar.f23179c != j13) {
                                                    fVar.b(j13);
                                                }
                                            }
                                        }
                                        s12 = (short) (s11 + 1);
                                        hashSet4 = hashSet3;
                                        str4 = str2;
                                        z13 = z12;
                                        readShort = s10;
                                    }
                                }
                            }
                        } else {
                            s11 = s12;
                        }
                        z10 = true;
                        if (z10) {
                        }
                    }
                }
                s10 = readShort;
                s11 = s12;
                hashSet = hashSet4;
                if (z13) {
                    Log.d(str4, "Skip the tag entry since data format is invalid: " + readUnsignedShort3);
                }
                j4 = 0;
                z11 = false;
                if (z11) {
                }
                s12 = (short) (s11 + 1);
                hashSet4 = hashSet3;
                str4 = str2;
                z13 = z12;
                readShort = s10;
            }
            hashSet = hashSet4;
            j4 = 0;
            z11 = false;
            if (z11) {
            }
            s12 = (short) (s11 + 1);
            hashSet4 = hashSet3;
            str4 = str2;
            z13 = z12;
            readShort = s10;
        }
        HashSet hashSet5 = hashSet4;
        String str6 = str4;
        boolean z14 = z13;
        int readInt3 = fVar.readInt();
        if (z14) {
            str = str6;
            Log.d(str, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
        } else {
            str = str6;
        }
        long j14 = readInt3;
        if (j14 > 0) {
            if (!hashSet5.contains(Integer.valueOf(readInt3))) {
                fVar.b(j14);
                if (hashMapArr[4].isEmpty()) {
                    s(fVar, 4);
                } else if (hashMapArr[5].isEmpty()) {
                    s(fVar, 5);
                }
            } else if (z14) {
                Log.d(str, "Stop reading file since re-reading an IFD may cause an infinite loop: " + readInt3);
            }
        } else if (z14) {
            Log.d(str, "Stop reading file since a wrong offset may cause an infinite loop: " + readInt3);
        }
    }

    public final void t(int i, String str, String str2) {
        HashMap<String, c>[] hashMapArr = this.f23166d;
        if (!hashMapArr[i].isEmpty() && hashMapArr[i].get(str) != null) {
            HashMap<String, c> hashMap = hashMapArr[i];
            hashMap.put(str2, hashMap.get(str));
            hashMapArr[i].remove(str);
        }
    }

    public final void u(b bVar) throws IOException {
        boolean z10;
        c cVar;
        int f10;
        HashMap<String, c> hashMap = this.f23166d[4];
        c cVar2 = hashMap.get("Compression");
        if (cVar2 != null) {
            int f11 = cVar2.f(this.f23168f);
            if (f11 != 1) {
                if (f11 != 6) {
                    if (f11 != 7) {
                        return;
                    }
                } else {
                    m(bVar, hashMap);
                    return;
                }
            }
            c cVar3 = hashMap.get("BitsPerSample");
            if (cVar3 != null) {
                int[] iArr = (int[]) cVar3.h(this.f23168f);
                int[] iArr2 = f23152o;
                if (Arrays.equals(iArr2, iArr) || (this.f23165c == 3 && (cVar = hashMap.get("PhotometricInterpretation")) != null && (((f10 = cVar.f(this.f23168f)) == 1 && Arrays.equals(iArr, f23153p)) || (f10 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z10 = true;
                    if (!z10) {
                        c cVar4 = hashMap.get("StripOffsets");
                        c cVar5 = hashMap.get("StripByteCounts");
                        if (cVar4 != null && cVar5 != null) {
                            long[] b10 = g1.b.b(cVar4.h(this.f23168f));
                            long[] b11 = g1.b.b(cVar5.h(this.f23168f));
                            if (b10 != null && b10.length != 0) {
                                if (b11 != null && b11.length != 0) {
                                    if (b10.length != b11.length) {
                                        Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                                        return;
                                    }
                                    long j4 = 0;
                                    for (long j10 : b11) {
                                        j4 += j10;
                                    }
                                    byte[] bArr = new byte[(int) j4];
                                    this.f23169g = true;
                                    int i = 0;
                                    int i10 = 0;
                                    for (int i11 = 0; i11 < b10.length; i11++) {
                                        int i12 = (int) b10[i11];
                                        int i13 = (int) b11[i11];
                                        if (i11 < b10.length - 1 && i12 + i13 != b10[i11 + 1]) {
                                            this.f23169g = false;
                                        }
                                        int i14 = i12 - i;
                                        if (i14 < 0) {
                                            Log.d("ExifInterface", "Invalid strip offset value");
                                            return;
                                        }
                                        long j11 = i14;
                                        if (bVar.skip(j11) != j11) {
                                            Log.d("ExifInterface", "Failed to skip " + i14 + " bytes.");
                                            return;
                                        }
                                        int i15 = i + i14;
                                        byte[] bArr2 = new byte[i13];
                                        if (bVar.read(bArr2) != i13) {
                                            Log.d("ExifInterface", "Failed to read " + i13 + " bytes.");
                                            return;
                                        }
                                        i = i15 + i13;
                                        System.arraycopy(bArr2, 0, bArr, i10, i13);
                                        i10 += i13;
                                    }
                                    if (this.f23169g) {
                                        long j12 = b10[0];
                                        return;
                                    }
                                    return;
                                }
                                Log.w("ExifInterface", "stripByteCounts should not be null or have zero length.");
                                return;
                            }
                            Log.w("ExifInterface", "stripOffsets should not be null or have zero length.");
                            return;
                        }
                        return;
                    }
                    return;
                }
            }
            if (f23149l) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z10 = false;
            if (!z10) {
            }
        } else {
            m(bVar, hashMap);
        }
    }

    public final void v(int i, int i10) throws IOException {
        HashMap<String, c>[] hashMapArr = this.f23166d;
        boolean isEmpty = hashMapArr[i].isEmpty();
        boolean z10 = f23149l;
        if (!isEmpty && !hashMapArr[i10].isEmpty()) {
            c cVar = hashMapArr[i].get("ImageLength");
            c cVar2 = hashMapArr[i].get("ImageWidth");
            c cVar3 = hashMapArr[i10].get("ImageLength");
            c cVar4 = hashMapArr[i10].get("ImageWidth");
            if (cVar != null && cVar2 != null) {
                if (cVar3 != null && cVar4 != null) {
                    int f10 = cVar.f(this.f23168f);
                    int f11 = cVar2.f(this.f23168f);
                    int f12 = cVar3.f(this.f23168f);
                    int f13 = cVar4.f(this.f23168f);
                    if (f10 < f12 && f11 < f13) {
                        HashMap<String, c> hashMap = hashMapArr[i];
                        hashMapArr[i] = hashMapArr[i10];
                        hashMapArr[i10] = hashMap;
                    }
                } else if (z10) {
                    Log.d("ExifInterface", "Second image does not contain valid size information");
                }
            } else if (z10) {
                Log.d("ExifInterface", "First image does not contain valid size information");
            }
        } else if (z10) {
            Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
        }
    }

    public final void w(f fVar, int i) throws IOException {
        c d10;
        c d11;
        HashMap<String, c>[] hashMapArr = this.f23166d;
        c cVar = hashMapArr[i].get("DefaultCropSize");
        c cVar2 = hashMapArr[i].get("SensorTopBorder");
        c cVar3 = hashMapArr[i].get("SensorLeftBorder");
        c cVar4 = hashMapArr[i].get("SensorBottomBorder");
        c cVar5 = hashMapArr[i].get("SensorRightBorder");
        if (cVar != null) {
            if (cVar.f23181a == 5) {
                e[] eVarArr = (e[]) cVar.h(this.f23168f);
                if (eVarArr != null && eVarArr.length == 2) {
                    d10 = c.c(eVarArr[0], this.f23168f);
                    d11 = c.c(eVarArr[1], this.f23168f);
                } else {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(eVarArr));
                    return;
                }
            } else {
                int[] iArr = (int[]) cVar.h(this.f23168f);
                if (iArr != null && iArr.length == 2) {
                    d10 = c.d(iArr[0], this.f23168f);
                    d11 = c.d(iArr[1], this.f23168f);
                } else {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(iArr));
                    return;
                }
            }
            hashMapArr[i].put("ImageWidth", d10);
            hashMapArr[i].put("ImageLength", d11);
        } else if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) {
            int f10 = cVar2.f(this.f23168f);
            int f11 = cVar4.f(this.f23168f);
            int f12 = cVar5.f(this.f23168f);
            int f13 = cVar3.f(this.f23168f);
            if (f11 > f10 && f12 > f13) {
                c d12 = c.d(f11 - f10, this.f23168f);
                c d13 = c.d(f12 - f13, this.f23168f);
                hashMapArr[i].put("ImageLength", d12);
                hashMapArr[i].put("ImageWidth", d13);
            }
        } else {
            c cVar6 = hashMapArr[i].get("ImageLength");
            c cVar7 = hashMapArr[i].get("ImageWidth");
            if (cVar6 == null || cVar7 == null) {
                c cVar8 = hashMapArr[i].get("JPEGInterchangeFormat");
                c cVar9 = hashMapArr[i].get("JPEGInterchangeFormatLength");
                if (cVar8 != null && cVar9 != null) {
                    int f14 = cVar8.f(this.f23168f);
                    int f15 = cVar8.f(this.f23168f);
                    fVar.b(f14);
                    byte[] bArr = new byte[f15];
                    fVar.read(bArr);
                    e(new b(bArr), f14, i);
                }
            }
        }
    }

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

    public static class f extends b {
        public f(byte[] bArr) throws IOException {
            super(bArr);
            this.f23177a.mark(Integer.MAX_VALUE);
        }

        public final void b(long j4) throws IOException {
            int i = this.f23179c;
            if (i > j4) {
                this.f23179c = 0;
                this.f23177a.reset();
            } else {
                j4 -= i;
            }
            a((int) j4);
        }

        public f(InputStream inputStream) throws IOException {
            super(inputStream);
            if (inputStream.markSupported()) {
                this.f23177a.mark(Integer.MAX_VALUE);
                return;
            }
            throw new IllegalArgumentException("Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset");
        }
    }

    public static class d {
        public final int f23185a;
        public final String f23186b;
        public final int f23187c;
        public final int f23188d;

        public d(String str, int i, int i10) {
            this.f23186b = str;
            this.f23185a = i;
            this.f23187c = i10;
            this.f23188d = -1;
        }

        public d(int i, int i10, int i11, String str) {
            this.f23186b = str;
            this.f23185a = i;
            this.f23187c = i10;
            this.f23188d = i11;
        }
    }
}