package defpackage;

import androidx.media3.common.ParserException;
import j$.util.Objects;
import java.io.EOFException;
import java.io.InterruptedIOException;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: renamed from: ˈᵕᵩ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1076 implements InterfaceC4291 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public InterfaceC4550 f4583;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public InterfaceC5206 f4584;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public int f4585;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public int f4586;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public C4583 f4587;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public C2568 f4589;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public int f4590;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public C1705 f4591;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C4545 f4588 = new C4545(2);

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public long f4592 = -1;

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo1252(long j, long j2) {
        if (j == 0) {
            this.f4585 = 0;
            this.f4587 = null;
        } else if (this.f4585 == 5) {
            C4583 c4583 = this.f4587;
            c4583.getClass();
            c4583.mo1252(j, j2);
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final void m3514() {
        InterfaceC4550 interfaceC4550 = this.f4583;
        interfaceC4550.getClass();
        interfaceC4550.mo2740();
        this.f4583.mo2739(new C3782(-9223372036854775807L));
        this.f4585 = 6;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final InterfaceC4291 mo1254() {
        return this;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵨᵣ */
    public final boolean mo1255(InterfaceC5206 interfaceC5206) throws EOFException, InterruptedIOException {
        String strM9605;
        C2373 c2373 = (C2373) interfaceC5206;
        C4545 c4545 = this.f4588;
        c4545.m9603(2);
        c2373.mo4708(c4545.f17284, 0, 2, false);
        if (c4545.m9598() == 65496) {
            while (true) {
                c4545.m9603(2);
                c2373.mo4708(c4545.f17284, 0, 2, false);
                int iM9598 = c4545.m9598();
                this.f4590 = iM9598;
                if (iM9598 == 65498) {
                    break;
                }
                c4545.m9603(2);
                c2373.mo4701(c4545.f17284, 0, 2);
                int iM95982 = c4545.m9598() - 2;
                if (iM95982 < 0) {
                    break;
                }
                if (this.f4590 != 65505) {
                    c2373.m6055(iM95982, false);
                } else {
                    c4545.m9603(iM95982);
                    c2373.mo4708(c4545.f17284, 0, iM95982, false);
                    if (Objects.equals(c4545.m9605(), "http://ns.adobe.com/xap/1.0/") && (strM9605 = c4545.m9605()) != null) {
                        String[] strArr = ᵲᵧˇ.ᵯᵷʽ;
                        for (int i = 0; i < 4; i++) {
                            if (strM9605.contains(strArr[i] + "=\"1\"")) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo1256() {
        C4583 c4583 = this.f4587;
        if (c4583 != null) {
            c4583.getClass();
        }
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo1257(InterfaceC4550 interfaceC4550) {
        this.f4583 = interfaceC4550;
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00fe  */
    /* JADX WARN: Removed duplicated region for block: B:91:0x0187  */
    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int mo1258(InterfaceC5206 interfaceC5206, C2669 c2669) throws ParserException {
        String strM9605;
        C1705 c1705;
        C2598 c2598;
        int i;
        C2568 c2568;
        long j;
        long j2;
        int i2 = this.f4585;
        long j3 = -1;
        C4545 c4545 = this.f4588;
        if (i2 == 0) {
            c4545.m9603(2);
            interfaceC5206.readFully(c4545.f17284, 0, 2);
            int iM9598 = c4545.m9598();
            this.f4590 = iM9598;
            if (iM9598 == 65498) {
                if (this.f4592 != -1) {
                    this.f4585 = 4;
                    return 0;
                }
                m3514();
                return 0;
            }
            if ((iM9598 < 65488 || iM9598 > 65497) && iM9598 != 65281) {
                this.f4585 = 1;
            }
            return 0;
        }
        if (i2 == 1) {
            c4545.m9603(2);
            interfaceC5206.mo4701(c4545.f17284, 0, 2);
            this.f4586 = c4545.m9598() - 2;
            interfaceC5206.mo4700(2);
            this.f4585 = 2;
            return 0;
        }
        if (i2 != 2) {
            if (i2 != 4) {
                if (i2 != 5) {
                    if (i2 == 6) {
                        return -1;
                    }
                    ᵷᵝˎ.ᵱʡˏ();
                    return 0;
                }
                if (this.f4591 == null || interfaceC5206 != this.f4584) {
                    this.f4584 = interfaceC5206;
                    this.f4591 = new C1705(interfaceC5206, this.f4592);
                }
                C4583 c4583 = this.f4587;
                c4583.getClass();
                int iMo1258 = c4583.mo1258(this.f4591, c2669);
                if (iMo1258 == 1) {
                    c2669.f10317 += this.f4592;
                }
                return iMo1258;
            }
            long position = interfaceC5206.getPosition();
            long j4 = this.f4592;
            if (position != j4) {
                c2669.f10317 = j4;
                return 1;
            }
            if (!interfaceC5206.mo4708(c4545.f17284, 0, 1, true)) {
                m3514();
                return 0;
            }
            interfaceC5206.mo4698();
            if (this.f4587 == null) {
                this.f4587 = new C4583(InterfaceC1471.f5974, 8);
            }
            C1705 c17052 = new C1705(interfaceC5206, this.f4592);
            this.f4591 = c17052;
            if (!this.f4587.mo1255(c17052)) {
                m3514();
                return 0;
            }
            C4583 c45832 = this.f4587;
            long j5 = this.f4592;
            InterfaceC4550 interfaceC4550 = this.f4583;
            interfaceC4550.getClass();
            c45832.mo1257(new C1705(j5, interfaceC4550, 6));
            C2568 c25682 = this.f4589;
            c25682.getClass();
            InterfaceC4550 interfaceC45502 = this.f4583;
            interfaceC45502.getClass();
            InterfaceC5226 interfaceC5226Mo2743 = interfaceC45502.mo2743(1024, 4);
            C4753 c4753 = new C4753();
            c4753.f18111 = AbstractC4208.m9132("image/jpeg");
            c4753.f18125 = new C1956(c25682);
            AbstractC0659.m2415(c4753, interfaceC5226Mo2743);
            this.f4585 = 5;
            return 0;
        }
        if (this.f4590 == 65505) {
            C4545 c45452 = new C4545(this.f4586);
            interfaceC5206.readFully(c45452.f17284, 0, this.f4586);
            if (this.f4589 == null && "http://ns.adobe.com/xap/1.0/".equals(c45452.m9605()) && (strM9605 = c45452.m9605()) != null) {
                long length = interfaceC5206.getLength();
                if (length == -1) {
                    c2568 = null;
                    this.f4589 = c2568;
                    if (c2568 != null) {
                        this.f4592 = c2568.f9918;
                    }
                } else {
                    try {
                        c1705 = ᵲᵧˇ.ˊᵨᵧ(strM9605);
                    } catch (ParserException | NumberFormatException | XmlPullParserException unused) {
                        ˋˀᵧ.ʿٴˇ("Ignoring unexpected XMP metadata");
                        c1705 = null;
                    }
                    if (c1705 != null && (i = (c2598 = (C2598) c1705.f6817).f10050) >= 2) {
                        int i3 = i - 1;
                        long j6 = -1;
                        long j7 = -1;
                        long j8 = -1;
                        long j9 = -1;
                        while (i3 >= 0) {
                            C3559 c3559 = (C3559) c2598.get(i3);
                            String str = c3559.f13630;
                            boolean z = str.equals("video/mp4") || str.equals("video/quicktime");
                            if (i3 == 0) {
                                j = j3;
                                length -= c3559.f13629;
                                j2 = 0;
                            } else {
                                j = j3;
                                j2 = length - c3559.f13628;
                            }
                            long j10 = length;
                            length = j2;
                            if (z && length != j10) {
                                j9 = j10 - length;
                                j8 = length;
                            }
                            if (i3 == 0) {
                                j7 = j10;
                                j6 = length;
                            }
                            i3--;
                            j3 = j;
                        }
                        long j11 = j3;
                        if (j8 != j11 && j9 != j11 && j6 != j11 && j7 != j11) {
                            c2568 = new C2568(j6, j7, c1705.f6818, j8, j9);
                        }
                        this.f4589 = c2568;
                        if (c2568 != null) {
                        }
                    }
                }
            }
        } else {
            interfaceC5206.mo4700(this.f4586);
        }
        this.f4585 = 0;
        return 0;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final List mo1259() {
        C2822 c2822 = AbstractC4509.f17159;
        return C2598.f10048;
    }
}
