MyRecorder v1.01.90.0219版本的 MD5 值为:c361f51174a0bf833abfa72929caf8d3

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


package g1;

import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import com.google.common.primitives.UnsignedBytes;
import com.google.firebase.sessions.settings.RemoteSettings;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
public class a {
    public static SimpleDateFormat W;
    public static final d[] f43685a0;
    public static final d[] f43686b0;
    public static final d[] f43687c0;
    public static final d[] f43688d0;
    public static final d[] f43689e0;
    public static final d f43690f0;
    public static final d[] f43691g0;
    public static final d[] f43692h0;
    public static final d[] f43693i0;
    public static final d[] f43694j0;
    public static final d[][] f43695k0;
    public static final d[] f43696l0;
    public static final d f43697m0;
    public static final d f43698n0;
    public static final HashMap<Integer, d>[] f43699o0;
    public static final HashMap<String, d>[] f43700p0;
    public static final HashSet<String> f43701q0;
    public static final HashMap<Integer, Integer> f43702r0;
    public static final Charset f43703s0;
    public static final byte[] f43704t0;
    public static final byte[] f43705u0;
    public static final Pattern f43706v0;
    public static final Pattern f43708w0;
    public String f43712a;
    public FileDescriptor f43713b;
    public AssetManager.AssetInputStream f43714c;
    public int f43715d;
    public boolean f43716e;
    public final HashMap<String, c>[] f43717f;
    public Set<Integer> f43718g;
    public ByteOrder f43719h;
    public boolean f43720i;
    public boolean f43721j;
    public boolean f43722k;
    public int f43723l;
    public int f43724m;
    public byte[] f43725n;
    public int f43726o;
    public int f43727p;
    public int f43728q;
    public int f43729r;
    public int f43730s;
    public int f43731t;
    public boolean f43732u;
    public boolean f43733v;
    public static final boolean f43707w = Log.isLoggable("ExifInterface", 3);
    public static final List<Integer> f43709x = Arrays.asList(1, 6, 3, 8);
    public static final List<Integer> f43710y = Arrays.asList(2, 7, 4, 5);
    public static final int[] f43711z = {8, 8, 8};
    public static final int[] A = {4};
    public static final int[] B = {8};
    public static final byte[] C = {-1, -40, -1};
    public static final byte[] D = {102, 116, 121, 112};
    public static final byte[] E = {109, 105, 102, 49};
    public static final byte[] F = {104, 101, 105, 99};
    public static final byte[] G = {79, 76, 89, 77, 80, 0};
    public static final byte[] H = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] I = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] J = {101, 88, 73, 102};
    public static final byte[] K = {73, 72, 68, 82};
    public static final byte[] L = {73, 69, 78, 68};
    public static final byte[] M = {82, 73, 70, 70};
    public static final byte[] N = {87, 69, 66, 80};
    public static final byte[] O = {69, 88, 73, 70};
    public static final byte[] P = {-99, 1, 42};
    public static final byte[] Q = "VP8X".getBytes(Charset.defaultCharset());
    public static final byte[] R = "VP8L".getBytes(Charset.defaultCharset());
    public static final byte[] S = "VP8 ".getBytes(Charset.defaultCharset());
    public static final byte[] T = "ANIM".getBytes(Charset.defaultCharset());
    public static final byte[] U = "ANMF".getBytes(Charset.defaultCharset());
    public static final byte[] V = "XMP ".getBytes(Charset.defaultCharset());
    public static final String[] X = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    public static final int[] Y = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    public static final byte[] Z = {65, 83, 67, 73, 73, 0, 0, 0};

    public class C0528a extends MediaDataSource {
        public long f43734a;
        public final b f43735b;

        public C0528a(b bVar) {
            this.f43735b = bVar;
        }

        @Override
        public void close() throws IOException {
        }

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

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

    public static class b extends InputStream implements DataInput {
        public static final ByteOrder f43737e = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder f43738f = ByteOrder.BIG_ENDIAN;
        public DataInputStream f43739a;
        public ByteOrder f43740b;
        public final int f43741c;
        public int f43742d;

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

        public b(InputStream inputStream, ByteOrder byteOrder) throws IOException {
            this.f43740b = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f43739a = dataInputStream;
            int available = dataInputStream.available();
            this.f43741c = available;
            this.f43742d = 0;
            this.f43739a.mark(available);
            this.f43740b = byteOrder;
        }

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

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

        public int e() {
            return this.f43741c;
        }

        public int f() {
            return this.f43742d;
        }

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

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

        public void j(ByteOrder byteOrder) {
            this.f43740b = byteOrder;
        }

        @Override
        public int read() throws IOException {
            this.f43742d++;
            return this.f43739a.read();
        }

        @Override
        public int read(byte[] bArr, int i10, int i11) throws IOException {
            int read = this.f43739a.read(bArr, i10, i11);
            this.f43742d += read;
            return read;
        }

        @Override
        public boolean readBoolean() throws IOException {
            this.f43742d++;
            return this.f43739a.readBoolean();
        }

        @Override
        public byte readByte() throws IOException {
            int i10 = this.f43742d + 1;
            this.f43742d = i10;
            if (i10 <= this.f43741c) {
                int read = this.f43739a.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public char readChar() throws IOException {
            this.f43742d += 2;
            return this.f43739a.readChar();
        }

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

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

        @Override
        public void readFully(byte[] bArr) throws IOException {
            int length = this.f43742d + bArr.length;
            this.f43742d = length;
            if (length > this.f43741c) {
                throw new EOFException();
            }
            if (this.f43739a.read(bArr, 0, bArr.length) != bArr.length) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override
        public void readFully(byte[] bArr, int i10, int i11) throws IOException {
            int i12 = this.f43742d + i11;
            this.f43742d = i12;
            if (i12 > this.f43741c) {
                throw new EOFException();
            }
            if (this.f43739a.read(bArr, i10, i11) != i11) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override
        public int readInt() throws IOException {
            int i10 = this.f43742d + 4;
            this.f43742d = i10;
            if (i10 <= this.f43741c) {
                int read = this.f43739a.read();
                int read2 = this.f43739a.read();
                int read3 = this.f43739a.read();
                int read4 = this.f43739a.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.f43740b;
                    if (byteOrder == f43737e) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f43738f) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    throw new IOException("Invalid byte order: " + this.f43740b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public String readLine() throws IOException {
            return null;
        }

        @Override
        public long readLong() throws IOException {
            int i10 = this.f43742d + 8;
            this.f43742d = i10;
            if (i10 <= this.f43741c) {
                int read = this.f43739a.read();
                int read2 = this.f43739a.read();
                int read3 = this.f43739a.read();
                int read4 = this.f43739a.read();
                int read5 = this.f43739a.read();
                int read6 = this.f43739a.read();
                int read7 = this.f43739a.read();
                int read8 = this.f43739a.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.f43740b;
                    if (byteOrder == f43737e) {
                        return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == f43738f) {
                        return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                    }
                    throw new IOException("Invalid byte order: " + this.f43740b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public short readShort() throws IOException {
            int i10 = this.f43742d + 2;
            this.f43742d = i10;
            if (i10 <= this.f43741c) {
                int read = this.f43739a.read();
                int read2 = this.f43739a.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f43740b;
                    if (byteOrder == f43737e) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == f43738f) {
                        return (short) ((read << 8) + read2);
                    }
                    throw new IOException("Invalid byte order: " + this.f43740b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public String readUTF() throws IOException {
            this.f43742d += 2;
            return this.f43739a.readUTF();
        }

        @Override
        public int readUnsignedByte() throws IOException {
            this.f43742d++;
            return this.f43739a.readUnsignedByte();
        }

        @Override
        public int readUnsignedShort() throws IOException {
            int i10 = this.f43742d + 2;
            this.f43742d = i10;
            if (i10 <= this.f43741c) {
                int read = this.f43739a.read();
                int read2 = this.f43739a.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f43740b;
                    if (byteOrder == f43737e) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == f43738f) {
                        return (read << 8) + read2;
                    }
                    throw new IOException("Invalid byte order: " + this.f43740b);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public int skipBytes(int i10) throws IOException {
            int min = Math.min(i10, this.f43741c - this.f43742d);
            int i11 = 0;
            while (i11 < min) {
                i11 += this.f43739a.skipBytes(min - i11);
            }
            this.f43742d += i11;
            return i11;
        }
    }

    public static class c {
        public final int f43743a;
        public final int f43744b;
        public final long f43745c;
        public final byte[] f43746d;

        public c(int i10, int i11, long j10, byte[] bArr) {
            this.f43743a = i10;
            this.f43744b = i11;
            this.f43745c = j10;
            this.f43746d = bArr;
        }

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

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

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

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

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

        public static c e(e[] eVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.Y[5] * eVarArr.length]);
            wrap.order(byteOrder);
            for (e eVar : eVarArr) {
                wrap.putInt((int) eVar.f43751a);
                wrap.putInt((int) eVar.f43752b);
            }
            return new c(5, eVarArr.length, wrap.array());
        }

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

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

        public double h(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 != null) {
                if (k10 instanceof String) {
                    return Double.parseDouble((String) k10);
                }
                if (k10 instanceof long[]) {
                    long[] jArr = (long[]) k10;
                    if (jArr.length == 1) {
                        return jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (k10 instanceof int[]) {
                    int[] iArr = (int[]) k10;
                    if (iArr.length == 1) {
                        return iArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (k10 instanceof double[]) {
                    double[] dArr = (double[]) k10;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (k10 instanceof e[]) {
                    e[] eVarArr = (e[]) k10;
                    if (eVarArr.length == 1) {
                        return eVarArr[0].a();
                    }
                    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 int i(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 != null) {
                if (k10 instanceof String) {
                    return Integer.parseInt((String) k10);
                }
                if (k10 instanceof long[]) {
                    long[] jArr = (long[]) k10;
                    if (jArr.length == 1) {
                        return (int) jArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                } else if (k10 instanceof int[]) {
                    int[] iArr = (int[]) k10;
                    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 String j(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 == null) {
                return null;
            }
            if (k10 instanceof String) {
                return (String) k10;
            }
            StringBuilder sb2 = new StringBuilder();
            int i10 = 0;
            if (k10 instanceof long[]) {
                long[] jArr = (long[]) k10;
                while (i10 < jArr.length) {
                    sb2.append(jArr[i10]);
                    i10++;
                    if (i10 != jArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (k10 instanceof int[]) {
                int[] iArr = (int[]) k10;
                while (i10 < iArr.length) {
                    sb2.append(iArr[i10]);
                    i10++;
                    if (i10 != iArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (k10 instanceof double[]) {
                double[] dArr = (double[]) k10;
                while (i10 < dArr.length) {
                    sb2.append(dArr[i10]);
                    i10++;
                    if (i10 != dArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else if (k10 instanceof e[]) {
                e[] eVarArr = (e[]) k10;
                while (i10 < eVarArr.length) {
                    sb2.append(eVarArr[i10].f43751a);
                    sb2.append('/');
                    sb2.append(eVarArr[i10].f43752b);
                    i10++;
                    if (i10 != eVarArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            } else {
                return null;
            }
        }

        public Object k(ByteOrder byteOrder) {
            b bVar;
            byte b10;
            byte[] bArr;
            b bVar2 = null;
            try {
                bVar = new b(this.f43746d);
                try {
                    bVar.j(byteOrder);
                    boolean z7 = true;
                    int i10 = 0;
                    switch (this.f43743a) {
                        case 1:
                        case 6:
                            byte[] bArr2 = this.f43746d;
                            if (bArr2.length != 1 || bArr2[0] < 0 || bArr2[0] > 1) {
                                String str = new String(bArr2, a.f43703s0);
                                try {
                                    bVar.close();
                                } catch (IOException e10) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                }
                                return str;
                            }
                            String str2 = new String(new char[]{(char) (bArr2[0] + 48)});
                            try {
                                bVar.close();
                            } catch (IOException e11) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                            }
                            return str2;
                        case 2:
                        case 7:
                            if (this.f43744b >= a.Z.length) {
                                int i11 = 0;
                                while (true) {
                                    bArr = a.Z;
                                    if (i11 < bArr.length) {
                                        if (this.f43746d[i11] != bArr[i11]) {
                                            z7 = false;
                                        } else {
                                            i11++;
                                        }
                                    }
                                }
                                if (z7) {
                                    i10 = bArr.length;
                                }
                            }
                            StringBuilder sb2 = new StringBuilder();
                            while (i10 < this.f43744b && (b10 = this.f43746d[i10]) != 0) {
                                if (b10 >= 32) {
                                    sb2.append((char) b10);
                                } else {
                                    sb2.append('?');
                                }
                                i10++;
                            }
                            String sb3 = sb2.toString();
                            try {
                                bVar.close();
                            } catch (IOException e12) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                            }
                            return sb3;
                        case 3:
                            int[] iArr = new int[this.f43744b];
                            while (i10 < this.f43744b) {
                                iArr[i10] = bVar.readUnsignedShort();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e13) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                            }
                            return iArr;
                        case 4:
                            long[] jArr = new long[this.f43744b];
                            while (i10 < this.f43744b) {
                                jArr[i10] = bVar.g();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e14) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                            }
                            return jArr;
                        case 5:
                            e[] eVarArr = new e[this.f43744b];
                            while (i10 < this.f43744b) {
                                eVarArr[i10] = new e(bVar.g(), bVar.g());
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e15) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                            }
                            return eVarArr;
                        case 8:
                            int[] iArr2 = new int[this.f43744b];
                            while (i10 < this.f43744b) {
                                iArr2[i10] = bVar.readShort();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e16) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                            }
                            return iArr2;
                        case 9:
                            int[] iArr3 = new int[this.f43744b];
                            while (i10 < this.f43744b) {
                                iArr3[i10] = bVar.readInt();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e17) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e17);
                            }
                            return iArr3;
                        case 10:
                            e[] eVarArr2 = new e[this.f43744b];
                            while (i10 < this.f43744b) {
                                eVarArr2[i10] = new e(bVar.readInt(), bVar.readInt());
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e18) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e18);
                            }
                            return eVarArr2;
                        case 11:
                            double[] dArr = new double[this.f43744b];
                            while (i10 < this.f43744b) {
                                dArr[i10] = bVar.readFloat();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e19) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e19);
                            }
                            return dArr;
                        case 12:
                            double[] dArr2 = new double[this.f43744b];
                            while (i10 < this.f43744b) {
                                dArr2[i10] = bVar.readDouble();
                                i10++;
                            }
                            try {
                                bVar.close();
                            } catch (IOException e20) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e20);
                            }
                            return dArr2;
                        default:
                            try {
                                bVar.close();
                            } catch (IOException e21) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e21);
                            }
                            return null;
                    }
                } catch (IOException unused) {
                    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;
                    bVar2 = bVar;
                    if (bVar2 != null) {
                        try {
                            bVar2.close();
                        } catch (IOException e23) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e23);
                        }
                    }
                    throw th;
                }
            } catch (IOException unused2) {
                bVar = null;
            } catch (Throwable th3) {
                th = th3;
            }
        }

        public String toString() {
            return "(" + a.X[this.f43743a] + ", data length:" + this.f43746d.length + ")";
        }
    }

    public static class d {
        public final int f43747a;
        public final String f43748b;
        public final int f43749c;
        public final int f43750d;

        public d(String str, int i10, int i11) {
            this.f43748b = str;
            this.f43747a = i10;
            this.f43749c = i11;
            this.f43750d = -1;
        }

        public d(String str, int i10, int i11, int i12) {
            this.f43748b = str;
            this.f43747a = i10;
            this.f43749c = i11;
            this.f43750d = i12;
        }

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

    public static class e {
        public final long f43751a;
        public final long f43752b;

        public e(long j10, long j11) {
            if (j11 == 0) {
                this.f43751a = 0L;
                this.f43752b = 1L;
                return;
            }
            this.f43751a = j10;
            this.f43752b = j11;
        }

        public double a() {
            return this.f43751a / this.f43752b;
        }

        public String toString() {
            return this.f43751a + RemoteSettings.FORWARD_SLASH_STRING + this.f43752b;
        }
    }

    static {
        d[] dVarArr;
        d[] dVarArr2 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ImageWidth", 256, 3, 4), new d("ImageLength", TsExtractor.TS_STREAM_TYPE_AIT, 3, 4), 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("StripOffsets", 273, 3, 4), new d("Orientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), 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", 305, 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", 514, 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", 700, 1)};
        f43685a0 = dVarArr2;
        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("PixelXDimension", 40962, 3, 4), new d("PixelYDimension", 40963, 3, 4), 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("DefaultCropSize", 50720, 3, 4)};
        f43686b0 = dVarArr3;
        d[] dVarArr4 = {new d("GPSVersionID", 0, 1), new d("GPSLatitudeRef", 1, 2), new d("GPSLatitude", 2, 5), new d("GPSLongitudeRef", 3, 2), new d("GPSLongitude", 4, 5), 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)};
        f43687c0 = dVarArr4;
        d[] dVarArr5 = {new d("InteroperabilityIndex", 1, 2)};
        f43688d0 = dVarArr5;
        d[] dVarArr6 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ThumbnailImageWidth", 256, 3, 4), new d("ThumbnailImageLength", TsExtractor.TS_STREAM_TYPE_AIT, 3, 4), 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("StripOffsets", 273, 3, 4), new d("ThumbnailOrientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), 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", 305, 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", 514, 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("DefaultCropSize", 50720, 3, 4)};
        f43689e0 = dVarArr6;
        f43690f0 = new d("StripOffsets", 273, 3);
        d[] dVarArr7 = {new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)};
        f43691g0 = dVarArr7;
        d[] dVarArr8 = {new d("PreviewImageStart", TsExtractor.TS_STREAM_TYPE_AIT, 4), new d("PreviewImageLength", 258, 4)};
        f43692h0 = dVarArr8;
        d[] dVarArr9 = {new d("AspectFrame", 4371, 3)};
        f43693i0 = dVarArr9;
        d[] dVarArr10 = {new d("ColorSpace", 55, 3)};
        f43694j0 = dVarArr10;
        d[][] dVarArr11 = {dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr6, dVarArr2, dVarArr7, dVarArr8, dVarArr9, dVarArr10};
        f43695k0 = dVarArr11;
        f43696l0 = 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)};
        f43697m0 = new d("JPEGInterchangeFormat", 513, 4);
        f43698n0 = new d("JPEGInterchangeFormatLength", 514, 4);
        f43699o0 = new HashMap[dVarArr11.length];
        f43700p0 = new HashMap[dVarArr11.length];
        f43701q0 = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        f43702r0 = new HashMap<>();
        Charset forName = Charset.forName(C.ASCII_NAME);
        f43703s0 = forName;
        f43704t0 = "Exif\u0000\u0000".getBytes(forName);
        f43705u0 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        W = simpleDateFormat;
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            d[][] dVarArr12 = f43695k0;
            if (i10 >= dVarArr12.length) {
                HashMap<Integer, Integer> hashMap = f43702r0;
                d[] dVarArr13 = f43696l0;
                hashMap.put(Integer.valueOf(dVarArr13[0].f43747a), 5);
                hashMap.put(Integer.valueOf(dVarArr13[1].f43747a), 1);
                hashMap.put(Integer.valueOf(dVarArr13[2].f43747a), 2);
                hashMap.put(Integer.valueOf(dVarArr13[3].f43747a), 3);
                hashMap.put(Integer.valueOf(dVarArr13[4].f43747a), 7);
                hashMap.put(Integer.valueOf(dVarArr13[5].f43747a), 8);
                f43706v0 = Pattern.compile(".*[1-9].*");
                f43708w0 = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
                return;
            }
            f43699o0[i10] = new HashMap<>();
            f43700p0[i10] = new HashMap<>();
            for (d dVar : dVarArr12[i10]) {
                f43699o0[i10].put(Integer.valueOf(dVar.f43747a), dVar);
                f43700p0[i10].put(dVar.f43748b, dVar);
            }
            i10++;
        }
    }

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

    public a(InputStream inputStream, boolean z7) throws IOException {
        d[][] dVarArr = f43695k0;
        this.f43717f = new HashMap[dVarArr.length];
        this.f43718g = new HashSet(dVarArr.length);
        this.f43719h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(inputStream, "inputStream cannot be null");
        this.f43712a = null;
        if (z7) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            if (!u(bufferedInputStream)) {
                return;
            }
            this.f43716e = true;
            this.f43714c = null;
            this.f43713b = null;
            inputStream = bufferedInputStream;
        } else if (inputStream instanceof AssetManager.AssetInputStream) {
            this.f43714c = (AssetManager.AssetInputStream) inputStream;
            this.f43713b = null;
        } else {
            if (inputStream instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) inputStream;
                if (B(fileInputStream.getFD())) {
                    this.f43714c = null;
                    this.f43713b = fileInputStream.getFD();
                }
            }
            this.f43714c = null;
            this.f43713b = null;
        }
        F(inputStream);
    }

    public a(String str) throws IOException {
        d[][] dVarArr = f43695k0;
        this.f43717f = new HashMap[dVarArr.length];
        this.f43718g = new HashSet(dVarArr.length);
        this.f43719h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(str, "filename cannot be null");
        t(str);
    }

    public static boolean B(FileDescriptor fileDescriptor) {
        try {
            Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_CUR);
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

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

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

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

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

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

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

    public final boolean A(byte[] bArr) throws IOException {
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder I2 = I(bVar2);
                this.f43719h = I2;
                bVar2.j(I2);
                boolean z7 = bVar2.readShort() == 85;
                bVar2.close();
                return z7;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                return false;
            } catch (Throwable th2) {
                th = th2;
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public final boolean C(HashMap hashMap) throws IOException {
        c cVar;
        c cVar2 = (c) hashMap.get("BitsPerSample");
        if (cVar2 != null) {
            int[] iArr = (int[]) cVar2.k(this.f43719h);
            int[] iArr2 = f43711z;
            if (Arrays.equals(iArr2, iArr)) {
                return true;
            }
            if (this.f43715d != 3 || (cVar = (c) hashMap.get("PhotometricInterpretation")) == null) {
                return false;
            }
            int i10 = cVar.i(this.f43719h);
            return (i10 == 1 && Arrays.equals(iArr, B)) || (i10 == 6 && Arrays.equals(iArr, iArr2));
        }
        return false;
    }

    public final boolean D(HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("ImageLength");
        c cVar2 = (c) hashMap.get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            return false;
        }
        return cVar.i(this.f43719h) <= 512 && cVar2.i(this.f43719h) <= 512;
    }

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

    public final void F(InputStream inputStream) {
        Objects.requireNonNull(inputStream, "inputstream shouldn't be null");
        for (int i10 = 0; i10 < f43695k0.length; i10++) {
            try {
                try {
                    this.f43717f[i10] = new HashMap<>();
                } catch (IOException unused) {
                    this.f43732u = false;
                    boolean z7 = f43707w;
                    a();
                    if (!z7) {
                        return;
                    }
                }
            } finally {
                a();
                if (f43707w) {
                    H();
                }
            }
        }
        if (!this.f43716e) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            this.f43715d = j(bufferedInputStream);
            inputStream = bufferedInputStream;
        }
        b bVar = new b(inputStream);
        if (!this.f43716e) {
            switch (this.f43715d) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    n(bVar);
                    break;
                case 4:
                    i(bVar, 0, 0);
                    break;
                case 7:
                    k(bVar);
                    break;
                case 9:
                    m(bVar);
                    break;
                case 10:
                    o(bVar);
                    break;
                case 12:
                    h(bVar);
                    break;
                case 13:
                    l(bVar);
                    break;
                case 14:
                    q(bVar);
                    break;
            }
        } else {
            p(bVar);
        }
        M(bVar);
        this.f43732u = true;
    }

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

    public final void H() {
        for (int i10 = 0; i10 < this.f43717f.length; i10++) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("The size of tag group[");
            sb2.append(i10);
            sb2.append("]: ");
            sb2.append(this.f43717f[i10].size());
            for (Map.Entry<String, c> entry : this.f43717f[i10].entrySet()) {
                c value = entry.getValue();
                StringBuilder sb3 = new StringBuilder();
                sb3.append("tagName: ");
                sb3.append(entry.getKey());
                sb3.append(", tagType: ");
                sb3.append(value.toString());
                sb3.append(", tagValue: '");
                sb3.append(value.j(this.f43719h));
                sb3.append("'");
            }
        }
    }

    public final ByteOrder I(b bVar) throws IOException {
        short readShort = bVar.readShort();
        if (readShort != 18761) {
            if (readShort == 19789) {
                return ByteOrder.BIG_ENDIAN;
            }
            throw new IOException("Invalid byte order: " + Integer.toHexString(readShort));
        }
        return ByteOrder.LITTLE_ENDIAN;
    }

    public final void J(byte[] bArr, int i10) throws IOException {
        b bVar = new b(bArr);
        G(bVar, bArr.length);
        K(bVar, i10);
    }

    public final void K(b bVar, int i10) throws IOException {
        long j10;
        int[] iArr;
        long j11;
        boolean z7;
        short s9;
        String str;
        short s10;
        int i11;
        int i12;
        int i13;
        int readUnsignedShort;
        this.f43718g.add(Integer.valueOf(bVar.f43742d));
        if (bVar.f43742d + 2 > bVar.f43741c) {
            return;
        }
        short readShort = bVar.readShort();
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("numberOfDirectoryEntry: ");
            sb2.append((int) readShort);
        }
        if (bVar.f43742d + (readShort * 12) > bVar.f43741c || readShort <= 0) {
            return;
        }
        char c10 = 0;
        short s11 = 0;
        while (s11 < readShort) {
            int readUnsignedShort2 = bVar.readUnsignedShort();
            int readUnsignedShort3 = bVar.readUnsignedShort();
            int readInt = bVar.readInt();
            long f10 = bVar.f() + 4;
            d dVar = f43699o0[i10].get(Integer.valueOf(readUnsignedShort2));
            boolean z9 = f43707w;
            if (z9) {
                Object[] objArr = new Object[5];
                objArr[c10] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                objArr[2] = dVar != null ? dVar.f43748b : null;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr);
            }
            if (dVar != null) {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < Y.length) {
                        if (dVar.a(readUnsignedShort3)) {
                            if (readUnsignedShort3 == 7) {
                                readUnsignedShort3 = dVar.f43749c;
                            }
                            j10 = f10;
                            j11 = readInt * iArr[readUnsignedShort3];
                            if (j11 < 0 || j11 > 2147483647L) {
                                if (z9) {
                                    StringBuilder sb3 = new StringBuilder();
                                    sb3.append("Skip the tag entry since the number of components is invalid: ");
                                    sb3.append(readInt);
                                }
                                z7 = false;
                            } else {
                                z7 = true;
                            }
                            if (z7) {
                                long j12 = j10;
                                if (j11 > 4) {
                                    int readInt2 = bVar.readInt();
                                    s9 = readShort;
                                    if (z9) {
                                        StringBuilder sb4 = new StringBuilder();
                                        s10 = s11;
                                        sb4.append("seek to data offset: ");
                                        sb4.append(readInt2);
                                    } else {
                                        s10 = s11;
                                    }
                                    int i14 = this.f43715d;
                                    if (i14 == 7) {
                                        if ("MakerNote".equals(dVar.f43748b)) {
                                            this.f43728q = readInt2;
                                        } else if (i10 == 6 && "ThumbnailImage".equals(dVar.f43748b)) {
                                            this.f43729r = readInt2;
                                            this.f43730s = readInt;
                                            c f11 = c.f(6, this.f43719h);
                                            i11 = readUnsignedShort2;
                                            i12 = readUnsignedShort3;
                                            c b10 = c.b(this.f43729r, this.f43719h);
                                            i13 = readInt;
                                            c b11 = c.b(this.f43730s, this.f43719h);
                                            this.f43717f[4].put("Compression", f11);
                                            this.f43717f[4].put("JPEGInterchangeFormat", b10);
                                            this.f43717f[4].put("JPEGInterchangeFormatLength", b11);
                                        }
                                        i11 = readUnsignedShort2;
                                        i12 = readUnsignedShort3;
                                        i13 = readInt;
                                    } else {
                                        i11 = readUnsignedShort2;
                                        i12 = readUnsignedShort3;
                                        i13 = readInt;
                                        if (i14 == 10 && "JpgFromRaw".equals(dVar.f43748b)) {
                                            this.f43731t = readInt2;
                                        }
                                    }
                                    long j13 = readInt2;
                                    str = "Compression";
                                    if (j13 + j11 <= bVar.f43741c) {
                                        bVar.h(j13);
                                    } else {
                                        if (z9) {
                                            StringBuilder sb5 = new StringBuilder();
                                            sb5.append("Skip the tag entry since data offset is invalid: ");
                                            sb5.append(readInt2);
                                        }
                                        bVar.h(j12);
                                    }
                                } else {
                                    s9 = readShort;
                                    str = "Compression";
                                    s10 = s11;
                                    i11 = readUnsignedShort2;
                                    i12 = readUnsignedShort3;
                                    i13 = readInt;
                                }
                                Integer num = f43702r0.get(Integer.valueOf(i11));
                                if (z9) {
                                    StringBuilder sb6 = new StringBuilder();
                                    sb6.append("nextIfdType: ");
                                    sb6.append(num);
                                    sb6.append(" byteCount: ");
                                    sb6.append(j11);
                                }
                                if (num != null) {
                                    long j14 = -1;
                                    int i15 = i12;
                                    if (i15 != 3) {
                                        if (i15 == 4) {
                                            j14 = bVar.g();
                                        } else if (i15 == 8) {
                                            readUnsignedShort = bVar.readShort();
                                        } else if (i15 == 9 || i15 == 13) {
                                            readUnsignedShort = bVar.readInt();
                                        }
                                        if (z9) {
                                            String.format("Offset: %d, tagName: %s", Long.valueOf(j14), dVar.f43748b);
                                        }
                                        if (j14 > 0 || j14 >= bVar.f43741c) {
                                            if (z9) {
                                                StringBuilder sb7 = new StringBuilder();
                                                sb7.append("Skip jump into the IFD since its offset is invalid: ");
                                                sb7.append(j14);
                                            }
                                        } else if (!this.f43718g.contains(Integer.valueOf((int) j14))) {
                                            bVar.h(j14);
                                            K(bVar, num.intValue());
                                        } else if (z9) {
                                            StringBuilder sb8 = new StringBuilder();
                                            sb8.append("Skip jump into the IFD since it has already been read: IfdType ");
                                            sb8.append(num);
                                            sb8.append(" (at ");
                                            sb8.append(j14);
                                            sb8.append(")");
                                        }
                                        bVar.h(j12);
                                    } else {
                                        readUnsignedShort = bVar.readUnsignedShort();
                                    }
                                    j14 = readUnsignedShort;
                                    if (z9) {
                                    }
                                    if (j14 > 0) {
                                    }
                                    if (z9) {
                                    }
                                    bVar.h(j12);
                                } else {
                                    int f12 = bVar.f() + this.f43727p;
                                    byte[] bArr = new byte[(int) j11];
                                    bVar.readFully(bArr);
                                    c cVar = new c(i12, i13, f12, bArr);
                                    this.f43717f[i10].put(dVar.f43748b, cVar);
                                    if ("DNGVersion".equals(dVar.f43748b)) {
                                        this.f43715d = 3;
                                    }
                                    if ((("Make".equals(dVar.f43748b) || "Model".equals(dVar.f43748b)) && cVar.j(this.f43719h).contains("PENTAX")) || (str.equals(dVar.f43748b) && cVar.i(this.f43719h) == 65535)) {
                                        this.f43715d = 8;
                                    }
                                    if (bVar.f() != j12) {
                                        bVar.h(j12);
                                    }
                                }
                                s11 = (short) (s10 + 1);
                                readShort = s9;
                                c10 = 0;
                            } else {
                                bVar.h(j10);
                                s9 = readShort;
                                s10 = s11;
                            }
                            s11 = (short) (s10 + 1);
                            readShort = s9;
                            c10 = 0;
                        } else if (z9) {
                            StringBuilder sb9 = new StringBuilder();
                            sb9.append("Skip the tag entry since data format (");
                            sb9.append(X[readUnsignedShort3]);
                            sb9.append(") is unexpected for tag: ");
                            sb9.append(dVar.f43748b);
                        }
                    }
                }
                j10 = f10;
                if (z9) {
                    StringBuilder sb10 = new StringBuilder();
                    sb10.append("Skip the tag entry since data format is invalid: ");
                    sb10.append(readUnsignedShort3);
                }
                z7 = false;
                j11 = 0;
                if (z7) {
                }
                s11 = (short) (s10 + 1);
                readShort = s9;
                c10 = 0;
            } else if (z9) {
                StringBuilder sb11 = new StringBuilder();
                sb11.append("Skip the tag entry since tag number is not defined: ");
                sb11.append(readUnsignedShort2);
            }
            j10 = f10;
            z7 = false;
            j11 = 0;
            if (z7) {
            }
            s11 = (short) (s10 + 1);
            readShort = s9;
            c10 = 0;
        }
        if (bVar.f() + 4 <= bVar.f43741c) {
            int readInt3 = bVar.readInt();
            boolean z10 = f43707w;
            if (z10) {
                String.format("nextIfdOffset: %d", Integer.valueOf(readInt3));
            }
            long j15 = readInt3;
            if (j15 <= 0 || readInt3 >= bVar.f43741c) {
                if (z10) {
                    StringBuilder sb12 = new StringBuilder();
                    sb12.append("Stop reading file since a wrong offset may cause an infinite loop: ");
                    sb12.append(readInt3);
                }
            } else if (this.f43718g.contains(Integer.valueOf(readInt3))) {
                if (z10) {
                    StringBuilder sb13 = new StringBuilder();
                    sb13.append("Stop reading file since re-reading an IFD may cause an infinite loop: ");
                    sb13.append(readInt3);
                }
            } else {
                bVar.h(j15);
                if (this.f43717f[4].isEmpty()) {
                    K(bVar, 4);
                } else if (this.f43717f[5].isEmpty()) {
                    K(bVar, 5);
                }
            }
        }
    }

    public final void L(b bVar, int i10) throws IOException {
        c cVar;
        c cVar2 = this.f43717f[i10].get("ImageLength");
        c cVar3 = this.f43717f[i10].get("ImageWidth");
        if ((cVar2 == null || cVar3 == null) && (cVar = this.f43717f[i10].get("JPEGInterchangeFormat")) != null) {
            i(bVar, cVar.i(this.f43719h), i10);
        }
    }

    public final void M(b bVar) throws IOException {
        HashMap<String, c> hashMap = this.f43717f[4];
        c cVar = hashMap.get("Compression");
        if (cVar == null) {
            this.f43726o = 6;
            r(bVar, hashMap);
            return;
        }
        int i10 = cVar.i(this.f43719h);
        this.f43726o = i10;
        if (i10 != 1) {
            if (i10 == 6) {
                r(bVar, hashMap);
                return;
            } else if (i10 != 7) {
                return;
            }
        }
        if (C(hashMap)) {
            s(bVar, hashMap);
        }
    }

    public final void O(int i10, int i11) throws IOException {
        if (this.f43717f[i10].isEmpty() || this.f43717f[i11].isEmpty()) {
            return;
        }
        c cVar = this.f43717f[i10].get("ImageLength");
        c cVar2 = this.f43717f[i10].get("ImageWidth");
        c cVar3 = this.f43717f[i11].get("ImageLength");
        c cVar4 = this.f43717f[i11].get("ImageWidth");
        if (cVar == null || cVar2 == null || cVar3 == null || cVar4 == null) {
            return;
        }
        int i12 = cVar.i(this.f43719h);
        int i13 = cVar2.i(this.f43719h);
        int i14 = cVar3.i(this.f43719h);
        int i15 = cVar4.i(this.f43719h);
        if (i12 >= i14 || i13 >= i15) {
            return;
        }
        HashMap<String, c>[] hashMapArr = this.f43717f;
        HashMap<String, c> hashMap = hashMapArr[i10];
        hashMapArr[i10] = hashMapArr[i11];
        hashMapArr[i11] = hashMap;
    }

    public final void P(b bVar, int i10) throws IOException {
        c f10;
        c f11;
        c cVar = this.f43717f[i10].get("DefaultCropSize");
        c cVar2 = this.f43717f[i10].get("SensorTopBorder");
        c cVar3 = this.f43717f[i10].get("SensorLeftBorder");
        c cVar4 = this.f43717f[i10].get("SensorBottomBorder");
        c cVar5 = this.f43717f[i10].get("SensorRightBorder");
        if (cVar == null) {
            if (cVar2 == null || cVar3 == null || cVar4 == null || cVar5 == null) {
                L(bVar, i10);
                return;
            }
            int i11 = cVar2.i(this.f43719h);
            int i12 = cVar4.i(this.f43719h);
            int i13 = cVar5.i(this.f43719h);
            int i14 = cVar3.i(this.f43719h);
            if (i12 <= i11 || i13 <= i14) {
                return;
            }
            c f12 = c.f(i12 - i11, this.f43719h);
            c f13 = c.f(i13 - i14, this.f43719h);
            this.f43717f[i10].put("ImageLength", f12);
            this.f43717f[i10].put("ImageWidth", f13);
            return;
        }
        if (cVar.f43743a == 5) {
            e[] eVarArr = (e[]) cVar.k(this.f43719h);
            if (eVarArr == null || eVarArr.length != 2) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Invalid crop size values. cropSize=");
                sb2.append(Arrays.toString(eVarArr));
                return;
            }
            f10 = c.d(eVarArr[0], this.f43719h);
            f11 = c.d(eVarArr[1], this.f43719h);
        } else {
            int[] iArr = (int[]) cVar.k(this.f43719h);
            if (iArr == null || iArr.length != 2) {
                StringBuilder sb3 = new StringBuilder();
                sb3.append("Invalid crop size values. cropSize=");
                sb3.append(Arrays.toString(iArr));
                return;
            }
            f10 = c.f(iArr[0], this.f43719h);
            f11 = c.f(iArr[1], this.f43719h);
        }
        this.f43717f[i10].put("ImageWidth", f10);
        this.f43717f[i10].put("ImageLength", f11);
    }

    public final void Q() throws IOException {
        O(0, 5);
        O(0, 4);
        O(5, 4);
        c cVar = this.f43717f[1].get("PixelXDimension");
        c cVar2 = this.f43717f[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            this.f43717f[0].put("ImageWidth", cVar);
            this.f43717f[0].put("ImageLength", cVar2);
        }
        if (this.f43717f[4].isEmpty() && D(this.f43717f[5])) {
            HashMap<String, c>[] hashMapArr = this.f43717f;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        D(this.f43717f[4]);
    }

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

    public String e(String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        c g7 = g(str);
        if (g7 != null) {
            if (!f43701q0.contains(str)) {
                return g7.j(this.f43719h);
            }
            if (str.equals("GPSTimeStamp")) {
                int i10 = g7.f43743a;
                if (i10 != 5 && i10 != 10) {
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append("GPS Timestamp format is not rational. format=");
                    sb2.append(g7.f43743a);
                    return null;
                }
                e[] eVarArr = (e[]) g7.k(this.f43719h);
                if (eVarArr == null || eVarArr.length != 3) {
                    StringBuilder sb3 = new StringBuilder();
                    sb3.append("Invalid GPS Timestamp array. array=");
                    sb3.append(Arrays.toString(eVarArr));
                    return null;
                }
                return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVarArr[0].f43751a) / ((float) eVarArr[0].f43752b))), Integer.valueOf((int) (((float) eVarArr[1].f43751a) / ((float) eVarArr[1].f43752b))), Integer.valueOf((int) (((float) eVarArr[2].f43751a) / ((float) eVarArr[2].f43752b))));
            }
            try {
                return Double.toString(g7.h(this.f43719h));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public int f(String str, int i10) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        c g7 = g(str);
        if (g7 == null) {
            return i10;
        }
        try {
            return g7.i(this.f43719h);
        } catch (NumberFormatException unused) {
            return i10;
        }
    }

    public final c g(String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        if ("ISOSpeedRatings".equals(str)) {
            str = "PhotographicSensitivity";
        }
        for (int i10 = 0; i10 < f43695k0.length; i10++) {
            c cVar = this.f43717f[i10].get(str);
            if (cVar != null) {
                return cVar;
            }
        }
        return null;
    }

    public final void h(b bVar) throws IOException {
        String str;
        String str2;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new C0528a(bVar));
            } else {
                FileDescriptor fileDescriptor = this.f43713b;
                if (fileDescriptor != null) {
                    mediaMetadataRetriever.setDataSource(fileDescriptor);
                } else {
                    String str3 = this.f43712a;
                    if (str3 == null) {
                        return;
                    }
                    mediaMetadataRetriever.setDataSource(str3);
                }
            }
            String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
            String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
            String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
            String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
            String str4 = null;
            if ("yes".equals(extractMetadata3)) {
                str4 = mediaMetadataRetriever.extractMetadata(29);
                str = mediaMetadataRetriever.extractMetadata(30);
                str2 = mediaMetadataRetriever.extractMetadata(31);
            } else if ("yes".equals(extractMetadata4)) {
                str4 = mediaMetadataRetriever.extractMetadata(18);
                str = mediaMetadataRetriever.extractMetadata(19);
                str2 = mediaMetadataRetriever.extractMetadata(24);
            } else {
                str = null;
                str2 = null;
            }
            if (str4 != null) {
                this.f43717f[0].put("ImageWidth", c.f(Integer.parseInt(str4), this.f43719h));
            }
            if (str != null) {
                this.f43717f[0].put("ImageLength", c.f(Integer.parseInt(str), this.f43719h));
            }
            if (str2 != null) {
                int i10 = 1;
                int parseInt = Integer.parseInt(str2);
                if (parseInt == 90) {
                    i10 = 6;
                } else if (parseInt == 180) {
                    i10 = 3;
                } else if (parseInt == 270) {
                    i10 = 8;
                }
                this.f43717f[0].put("Orientation", c.f(i10, this.f43719h));
            }
            if (extractMetadata != null && extractMetadata2 != null) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 <= 6) {
                    throw new IOException("Invalid exif length");
                }
                bVar.h(parseInt2);
                byte[] bArr = new byte[6];
                if (bVar.read(bArr) != 6) {
                    throw new IOException("Can't read identifier");
                }
                int i11 = parseInt2 + 6;
                int i12 = parseInt3 - 6;
                if (!Arrays.equals(bArr, f43704t0)) {
                    throw new IOException("Invalid identifier");
                }
                byte[] bArr2 = new byte[i12];
                if (bVar.read(bArr2) != i12) {
                    throw new IOException("Can't read exif");
                }
                this.f43727p = i11;
                J(bArr2, 0);
            }
            if (f43707w) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Heif meta: ");
                sb2.append(str4);
                sb2.append("x");
                sb2.append(str);
                sb2.append(", rotation ");
                sb2.append(str2);
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void i(b bVar, int i10, int i11) throws IOException {
        byte readByte;
        byte readByte2;
        int i12;
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("getJpegAttributes starting with: ");
            sb2.append(bVar);
        }
        bVar.j(ByteOrder.BIG_ENDIAN);
        bVar.h(i10);
        byte b10 = -1;
        if (bVar.readByte() != -1) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & UnsignedBytes.MAX_VALUE));
        }
        int i13 = 1;
        int i14 = i10 + 1;
        if (bVar.readByte() != -40) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & UnsignedBytes.MAX_VALUE));
        }
        int i15 = i14 + 1;
        while (true) {
            if (bVar.readByte() != b10) {
                throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & UnsignedBytes.MAX_VALUE));
            }
            int i16 = i15 + i13;
            byte readByte3 = bVar.readByte();
            boolean z7 = f43707w;
            if (z7) {
                StringBuilder sb3 = new StringBuilder();
                sb3.append("Found JPEG segment indicator: ");
                sb3.append(Integer.toHexString(readByte3 & UnsignedBytes.MAX_VALUE));
            }
            int i17 = i16 + i13;
            if (readByte3 != -39 && readByte3 != -38) {
                int readUnsignedShort = bVar.readUnsignedShort() - 2;
                int i18 = i17 + 2;
                if (z7) {
                    StringBuilder sb4 = new StringBuilder();
                    sb4.append("JPEG segment: ");
                    sb4.append(Integer.toHexString(readByte3 & UnsignedBytes.MAX_VALUE));
                    sb4.append(" (length: ");
                    sb4.append(readUnsignedShort + 2);
                    sb4.append(")");
                }
                if (readUnsignedShort < 0) {
                    throw new IOException("Invalid length");
                }
                if (readByte3 == -31) {
                    byte[] bArr = new byte[readUnsignedShort];
                    bVar.readFully(bArr);
                    i12 = i18 + readUnsignedShort;
                    byte[] bArr2 = f43704t0;
                    if (N(bArr, bArr2)) {
                        byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                        this.f43727p = i18 + bArr2.length;
                        J(copyOfRange, i11);
                    } else {
                        byte[] bArr3 = f43705u0;
                        if (N(bArr, bArr3)) {
                            int length = i18 + bArr3.length;
                            byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                            if (e("Xmp") == null) {
                                this.f43717f[0].put("Xmp", new c(1, copyOfRange2.length, length, copyOfRange2));
                                this.f43733v = true;
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 0) {
                                }
                            }
                        }
                    }
                } else if (readByte3 != -2) {
                    switch (readByte3) {
                        default:
                            switch (readByte3) {
                                default:
                                    switch (readByte3) {
                                        default:
                                            switch (readByte3) {
                                            }
                                        case -55:
                                        case -54:
                                        case -53:
                                            if (bVar.skipBytes(i13) != i13) {
                                                throw new IOException("Invalid SOFx");
                                            }
                                            this.f43717f[i11].put("ImageLength", c.b(bVar.readUnsignedShort(), this.f43719h));
                                            this.f43717f[i11].put("ImageWidth", c.b(bVar.readUnsignedShort(), this.f43719h));
                                            readUnsignedShort -= 5;
                                            break;
                                    }
                                case -59:
                                case -58:
                                case -57:
                                    break;
                            }
                        case -64:
                        case -63:
                        case -62:
                        case -61:
                            break;
                    }
                    i12 = i18;
                    if (readUnsignedShort < 0) {
                        throw new IOException("Invalid length");
                    }
                    if (bVar.skipBytes(readUnsignedShort) != readUnsignedShort) {
                        throw new IOException("Invalid JPEG segment");
                    }
                    i15 = i12 + readUnsignedShort;
                    b10 = -1;
                    i13 = 1;
                } else {
                    byte[] bArr4 = new byte[readUnsignedShort];
                    if (bVar.read(bArr4) != readUnsignedShort) {
                        throw new IOException("Invalid exif");
                    }
                    if (e("UserComment") == null) {
                        this.f43717f[i13].put("UserComment", c.a(new String(bArr4, f43703s0)));
                    }
                    i12 = i18;
                }
                readUnsignedShort = 0;
                if (readUnsignedShort < 0) {
                }
            }
        }
    }

    public final int j(BufferedInputStream bufferedInputStream) throws IOException {
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        if (w(bArr)) {
            return 4;
        }
        if (z(bArr)) {
            return 9;
        }
        if (v(bArr)) {
            return 12;
        }
        if (x(bArr)) {
            return 7;
        }
        if (A(bArr)) {
            return 10;
        }
        if (y(bArr)) {
            return 13;
        }
        return E(bArr) ? 14 : 0;
    }

    public final void k(b bVar) throws IOException {
        n(bVar);
        c cVar = this.f43717f[1].get("MakerNote");
        if (cVar != null) {
            b bVar2 = new b(cVar.f43746d);
            bVar2.j(this.f43719h);
            byte[] bArr = G;
            byte[] bArr2 = new byte[bArr.length];
            bVar2.readFully(bArr2);
            bVar2.h(0L);
            byte[] bArr3 = H;
            byte[] bArr4 = new byte[bArr3.length];
            bVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                bVar2.h(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                bVar2.h(12L);
            }
            K(bVar2, 6);
            c cVar2 = this.f43717f[7].get("PreviewImageStart");
            c cVar3 = this.f43717f[7].get("PreviewImageLength");
            if (cVar2 != null && cVar3 != null) {
                this.f43717f[5].put("JPEGInterchangeFormat", cVar2);
                this.f43717f[5].put("JPEGInterchangeFormatLength", cVar3);
            }
            c cVar4 = this.f43717f[8].get("AspectFrame");
            if (cVar4 != null) {
                int[] iArr = (int[]) cVar4.k(this.f43719h);
                if (iArr == null || iArr.length != 4) {
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append("Invalid aspect frame values. frame=");
                    sb2.append(Arrays.toString(iArr));
                } else if (iArr[2] <= iArr[0] || iArr[3] <= iArr[1]) {
                } else {
                    int i10 = (iArr[2] - iArr[0]) + 1;
                    int i11 = (iArr[3] - iArr[1]) + 1;
                    if (i10 < i11) {
                        int i12 = i10 + i11;
                        i11 = i12 - i11;
                        i10 = i12 - i11;
                    }
                    c f10 = c.f(i10, this.f43719h);
                    c f11 = c.f(i11, this.f43719h);
                    this.f43717f[0].put("ImageWidth", f10);
                    this.f43717f[0].put("ImageLength", f11);
                }
            }
        }
    }

    public final void l(b bVar) throws IOException {
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("getPngAttributes starting with: ");
            sb2.append(bVar);
        }
        bVar.j(ByteOrder.BIG_ENDIAN);
        byte[] bArr = I;
        bVar.skipBytes(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = bVar.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) != 4) {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
                int i11 = i10 + 4;
                if (i11 == 16 && !Arrays.equals(bArr2, K)) {
                    throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                }
                if (Arrays.equals(bArr2, L)) {
                    return;
                }
                if (Arrays.equals(bArr2, J)) {
                    byte[] bArr3 = new byte[readInt];
                    if (bVar.read(bArr3) != readInt) {
                        throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr2));
                    }
                    int readInt2 = bVar.readInt();
                    CRC32 crc32 = new CRC32();
                    crc32.update(bArr2);
                    crc32.update(bArr3);
                    if (((int) crc32.getValue()) == readInt2) {
                        this.f43727p = i11;
                        J(bArr3, 0);
                        Q();
                        return;
                    }
                    throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                }
                int i12 = readInt + 4;
                bVar.skipBytes(i12);
                length = i11 + i12;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final void m(b bVar) throws IOException {
        bVar.skipBytes(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        bVar.read(bArr);
        bVar.skipBytes(4);
        bVar.read(bArr2);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        i(bVar, i10, 5);
        bVar.h(i11);
        bVar.j(ByteOrder.BIG_ENDIAN);
        int readInt = bVar.readInt();
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("numberOfDirectoryEntry: ");
            sb2.append(readInt);
        }
        for (int i12 = 0; i12 < readInt; i12++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == f43690f0.f43747a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c f10 = c.f(readShort, this.f43719h);
                c f11 = c.f(readShort2, this.f43719h);
                this.f43717f[0].put("ImageLength", f10);
                this.f43717f[0].put("ImageWidth", f11);
                if (f43707w) {
                    StringBuilder sb3 = new StringBuilder();
                    sb3.append("Updated to length: ");
                    sb3.append((int) readShort);
                    sb3.append(", width: ");
                    sb3.append((int) readShort2);
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    public final void n(b bVar) throws IOException {
        c cVar;
        G(bVar, bVar.available());
        K(bVar, 0);
        P(bVar, 0);
        P(bVar, 5);
        P(bVar, 4);
        Q();
        if (this.f43715d != 8 || (cVar = this.f43717f[1].get("MakerNote")) == null) {
            return;
        }
        b bVar2 = new b(cVar.f43746d);
        bVar2.j(this.f43719h);
        bVar2.h(6L);
        K(bVar2, 9);
        c cVar2 = this.f43717f[9].get("ColorSpace");
        if (cVar2 != null) {
            this.f43717f[1].put("ColorSpace", cVar2);
        }
    }

    public final void o(b bVar) throws IOException {
        n(bVar);
        if (this.f43717f[0].get("JpgFromRaw") != null) {
            i(bVar, this.f43731t, 5);
        }
        c cVar = this.f43717f[0].get("ISO");
        c cVar2 = this.f43717f[1].get("PhotographicSensitivity");
        if (cVar == null || cVar2 != null) {
            return;
        }
        this.f43717f[1].put("PhotographicSensitivity", cVar);
    }

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

    public final void q(b bVar) throws IOException {
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("getWebpAttributes starting with: ");
            sb2.append(bVar);
        }
        bVar.j(ByteOrder.LITTLE_ENDIAN);
        bVar.skipBytes(M.length);
        int readInt = bVar.readInt() + 8;
        int skipBytes = bVar.skipBytes(N.length) + 8;
        while (true) {
            try {
                byte[] bArr = new byte[4];
                if (bVar.read(bArr) != 4) {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
                int readInt2 = bVar.readInt();
                int i10 = skipBytes + 4 + 4;
                if (Arrays.equals(O, bArr)) {
                    byte[] bArr2 = new byte[readInt2];
                    if (bVar.read(bArr2) == readInt2) {
                        this.f43727p = i10;
                        J(bArr2, 0);
                        this.f43727p = i10;
                        return;
                    }
                    throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr));
                }
                if (readInt2 % 2 == 1) {
                    readInt2++;
                }
                int i11 = i10 + readInt2;
                if (i11 == readInt) {
                    return;
                }
                if (i11 > readInt) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                int skipBytes2 = bVar.skipBytes(readInt2);
                if (skipBytes2 != readInt2) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                skipBytes = i10 + skipBytes2;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void r(b bVar, HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int i10 = cVar.i(this.f43719h);
        int i11 = cVar2.i(this.f43719h);
        if (this.f43715d == 7) {
            i10 += this.f43728q;
        }
        int min = Math.min(i11, bVar.e() - i10);
        if (i10 > 0 && min > 0) {
            this.f43720i = true;
            int i12 = this.f43727p + i10;
            this.f43723l = i12;
            this.f43724m = min;
            if (this.f43712a == null && this.f43714c == null && this.f43713b == null) {
                byte[] bArr = new byte[min];
                bVar.h(i12);
                bVar.readFully(bArr);
                this.f43725n = bArr;
            }
        }
        if (f43707w) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("Setting thumbnail attributes with offset: ");
            sb2.append(i10);
            sb2.append(", length: ");
            sb2.append(min);
        }
    }

    public final void s(b bVar, HashMap hashMap) throws IOException {
        c cVar = (c) hashMap.get("StripOffsets");
        c cVar2 = (c) hashMap.get("StripByteCounts");
        if (cVar == null || cVar2 == null) {
            return;
        }
        long[] d10 = d(cVar.k(this.f43719h));
        long[] d11 = d(cVar2.k(this.f43719h));
        if (d10 == null || d10.length == 0 || d11 == null || d11.length == 0 || d10.length != d11.length) {
            return;
        }
        long j10 = 0;
        for (long j11 : d11) {
            j10 += j11;
        }
        int i10 = (int) j10;
        byte[] bArr = new byte[i10];
        this.f43722k = true;
        this.f43721j = true;
        this.f43720i = true;
        int i11 = 0;
        int i12 = 0;
        for (int i13 = 0; i13 < d10.length; i13++) {
            int i14 = (int) d10[i13];
            int i15 = (int) d11[i13];
            if (i13 < d10.length - 1 && i14 + i15 != d10[i13 + 1]) {
                this.f43722k = false;
            }
            int i16 = i14 - i11;
            bVar.h(i16);
            int i17 = i11 + i16;
            byte[] bArr2 = new byte[i15];
            bVar.read(bArr2);
            i11 = i17 + i15;
            System.arraycopy(bArr2, 0, bArr, i12, i15);
            i12 += i15;
        }
        this.f43725n = bArr;
        if (this.f43722k) {
            this.f43723l = ((int) d10[0]) + this.f43727p;
            this.f43724m = i10;
        }
    }

    public final void t(String str) throws IOException {
        Objects.requireNonNull(str, "filename cannot be null");
        FileInputStream fileInputStream = null;
        this.f43714c = null;
        this.f43712a = str;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(str);
            try {
                if (B(fileInputStream2.getFD())) {
                    this.f43713b = fileInputStream2.getFD();
                } else {
                    this.f43713b = null;
                }
                F(fileInputStream2);
                c(fileInputStream2);
            } catch (Throwable th2) {
                th = th2;
                fileInputStream = fileInputStream2;
                c(fileInputStream);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public final boolean v(byte[] bArr) throws IOException {
        b bVar;
        long readInt;
        byte[] bArr2;
        b bVar2 = null;
        try {
            try {
                bVar = new b(bArr);
            } catch (Exception unused) {
            }
        } catch (Throwable th2) {
            th = th2;
        }
        try {
            readInt = bVar.readInt();
            bArr2 = new byte[4];
            bVar.read(bArr2);
        } catch (Exception unused2) {
            bVar2 = bVar;
            boolean z7 = f43707w;
            if (bVar2 != null) {
                bVar2.close();
            }
            return false;
        } catch (Throwable th3) {
            th = th3;
            bVar2 = bVar;
            if (bVar2 != null) {
                bVar2.close();
            }
            throw th;
        }
        if (!Arrays.equals(bArr2, D)) {
            bVar.close();
            return false;
        }
        long j10 = 16;
        if (readInt == 1) {
            readInt = bVar.readLong();
            if (readInt < 16) {
                bVar.close();
                return false;
            }
        } else {
            j10 = 8;
        }
        if (readInt > bArr.length) {
            readInt = bArr.length;
        }
        long j11 = readInt - j10;
        if (j11 < 8) {
            bVar.close();
            return false;
        }
        byte[] bArr3 = new byte[4];
        boolean z9 = false;
        boolean z10 = false;
        for (long j12 = 0; j12 < j11 / 4; j12++) {
            if (bVar.read(bArr3) != 4) {
                bVar.close();
                return false;
            }
            if (j12 != 1) {
                if (Arrays.equals(bArr3, E)) {
                    z9 = true;
                } else if (Arrays.equals(bArr3, F)) {
                    z10 = true;
                }
                if (z9 && z10) {
                    bVar.close();
                    return true;
                }
            }
        }
        bVar.close();
        return false;
    }

    public final boolean x(byte[] bArr) throws IOException {
        boolean z7 = false;
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder I2 = I(bVar2);
                this.f43719h = I2;
                bVar2.j(I2);
                short readShort = bVar2.readShort();
                z7 = (readShort == 20306 || readShort == 21330) ? true : true;
                bVar2.close();
                return z7;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                return false;
            } catch (Throwable th2) {
                th = th2;
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
        } catch (Throwable th3) {
            th = th3;
        }
    }

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

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