package p138.p176.p177.p190.p198.p207;

import android.util.Log;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.p198.InterfaceC3562;
import p138.p176.p177.p190.p198.p207.InterfaceC3690;
import p138.p176.p177.p190.p239.C4139;
import p138.p176.p177.p190.p239.C4140;
import p138.p176.p177.p190.p239.C4149;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ೲ.ޝ.ޏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3673 implements InterfaceC3690 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC3660 f11286;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C4139 f11287 = new C4139(new byte[10]);

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public int f11288 = 0;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public int f11289;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public C4149 f11290;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean f11291;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public boolean f11292;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public boolean f11293;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public int f11294;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public int f11295;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public boolean f11296;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public long f11297;

    public C3673(InterfaceC3660 interfaceC3660) {
        this.f11286 = interfaceC3660;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3690
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void mo6022() {
        this.f11288 = 0;
        this.f11289 = 0;
        this.f11293 = false;
        this.f11286.mo5997();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m6023(int i) {
        this.f11288 = i;
        this.f11289 = 0;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3690
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void mo6024(C4140 c4140, int i) {
        boolean z;
        int i2 = -1;
        int i3 = 3;
        if ((i & 1) != 0) {
            int i4 = this.f11288;
            if (i4 != 0 && i4 != 1) {
                if (i4 == 2) {
                    Log.w("PesReader", "Unexpected start indicator reading extended header");
                } else {
                    if (i4 != 3) {
                        throw new IllegalStateException();
                    }
                    if (this.f11295 != -1) {
                        StringBuilder sbM4889 = C2803.m4889("Unexpected start indicator: expected ");
                        sbM4889.append(this.f11295);
                        sbM4889.append(" more bytes");
                        Log.w("PesReader", sbM4889.toString());
                    }
                    this.f11286.mo6001();
                }
            }
            m6023(1);
        }
        while (c4140.m6679() > 0) {
            int i5 = this.f11288;
            if (i5 != 0) {
                if (i5 != 1) {
                    if (i5 == 2) {
                        if (m6026(c4140, this.f11287.f13223, Math.min(10, this.f11294)) && m6026(c4140, (byte[]) null, this.f11294)) {
                            this.f11287.m6672(0);
                            this.f11297 = -9223372036854775807L;
                            if (this.f11291) {
                                this.f11287.m6675(4);
                                long jM6667 = ((long) this.f11287.m6667(i3)) << 30;
                                this.f11287.m6675(1);
                                long jM66672 = jM6667 | ((long) (this.f11287.m6667(15) << 15));
                                this.f11287.m6675(1);
                                long jM66673 = jM66672 | ((long) this.f11287.m6667(15));
                                this.f11287.m6675(1);
                                if (!this.f11293 && this.f11292) {
                                    this.f11287.m6675(4);
                                    long jM66674 = ((long) this.f11287.m6667(i3)) << 30;
                                    this.f11287.m6675(1);
                                    long jM66675 = jM66674 | ((long) (this.f11287.m6667(15) << 15));
                                    this.f11287.m6675(1);
                                    long jM66676 = jM66675 | ((long) this.f11287.m6667(15));
                                    this.f11287.m6675(1);
                                    this.f11290.m6737(jM66676);
                                    this.f11293 = true;
                                }
                                this.f11297 = this.f11290.m6737(jM66673);
                            }
                            i |= this.f11296 ? 4 : 0;
                            this.f11286.mo5998(this.f11297, i);
                            m6023(3);
                        }
                    } else {
                        if (i5 != i3) {
                            throw new IllegalStateException();
                        }
                        int iM6679 = c4140.m6679();
                        int i6 = this.f11295;
                        int i7 = i6 != i2 ? iM6679 - i6 : 0;
                        if (i7 > 0) {
                            iM6679 -= i7;
                            c4140.m6691(c4140.f13228 + iM6679);
                        }
                        this.f11286.mo6000(c4140);
                        int i8 = this.f11295;
                        if (i8 != i2) {
                            int i9 = i8 - iM6679;
                            this.f11295 = i9;
                            if (i9 == 0) {
                                this.f11286.mo6001();
                                m6023(1);
                            }
                        }
                    }
                } else if (m6026(c4140, this.f11287.f13223, 9)) {
                    this.f11287.m6672(0);
                    int iM6667 = this.f11287.m6667(24);
                    if (iM6667 != 1) {
                        C2803.m4900("Unexpected start code prefix: ", iM6667, "PesReader");
                        this.f11295 = -1;
                        z = false;
                    } else {
                        this.f11287.m6675(8);
                        int iM66672 = this.f11287.m6667(16);
                        this.f11287.m6675(5);
                        this.f11296 = this.f11287.m6677();
                        this.f11287.m6675(2);
                        this.f11291 = this.f11287.m6677();
                        this.f11292 = this.f11287.m6677();
                        this.f11287.m6675(6);
                        int iM66673 = this.f11287.m6667(8);
                        this.f11294 = iM66673;
                        if (iM66672 == 0) {
                            this.f11295 = -1;
                        } else {
                            this.f11295 = ((iM66672 + 6) - 9) - iM66673;
                        }
                        z = true;
                    }
                    m6023(z ? 2 : 0);
                }
            } else {
                c4140.m6695(c4140.m6679());
            }
            i2 = -1;
            i3 = 3;
        }
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3690
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo6025(C4149 c4149, InterfaceC3562 interfaceC3562, InterfaceC3690.C3694 c3694) {
        this.f11290 = c4149;
        this.f11286.mo5999(interfaceC3562, c3694);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m6026(C4140 c4140, byte[] bArr, int i) {
        int iMin = Math.min(c4140.m6679(), i - this.f11289);
        if (iMin <= 0) {
            return true;
        }
        if (bArr == null) {
            c4140.m6695(iMin);
        } else {
            System.arraycopy(c4140.f13227, c4140.f13228, bArr, this.f11289, iMin);
            c4140.f13228 += iMin;
        }
        int i2 = this.f11289 + iMin;
        this.f11289 = i2;
        return i2 == i;
    }
}
