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

import android.util.Pair;
import com.google.android.exoplayer2.ParserException;
import java.util.Collections;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p198.InterfaceC3562;
import p138.p176.p177.p190.p198.InterfaceC3575;
import p138.p176.p177.p190.p198.p207.InterfaceC3690;
import p138.p176.p177.p190.p239.C4121;
import p138.p176.p177.p190.p239.C4139;
import p138.p176.p177.p190.p239.C4140;

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

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

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C4140 f11250;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C4139 f11251;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public C3670(String str) {
        this.f11249 = str;
        C4140 c4140 = new C4140(1024);
        this.f11250 = c4140;
        this.f11251 = new C4139(c4140.f13227);
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static long m6016(C4139 c4139) {
        return c4139.m6667((c4139.m6667(2) + 1) * 8);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m6017(C4139 c4139) throws ParserException {
        int iM6671 = c4139.m6671();
        Pair<Integer, Integer> pairM6621 = C4121.m6621(c4139, true);
        this.f11266 = ((Integer) pairM6621.first).intValue();
        this.f11268 = ((Integer) pairM6621.second).intValue();
        return iM6671 - c4139.m6671();
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5997() {
        this.f11255 = 0;
        this.f11260 = false;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5998(long j, int i) {
        this.f11259 = j;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5999(InterfaceC3562 interfaceC3562, InterfaceC3690.C3694 c3694) {
        c3694.m6035();
        this.f11252 = interfaceC3562.mo5891(c3694.m6037(), 1);
        this.f11254 = c3694.m6036();
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo6000(C4140 c4140) throws ParserException {
        int i;
        boolean zM6677;
        while (c4140.m6679() > 0) {
            int i2 = this.f11255;
            if (i2 != 0) {
                if (i2 == 1) {
                    int iM6702 = c4140.m6702();
                    if ((iM6702 & 224) == 224) {
                        this.f11258 = iM6702;
                        this.f11255 = 2;
                    } else if (iM6702 != 86) {
                        this.f11255 = 0;
                    }
                } else if (i2 == 2) {
                    int iM67022 = ((this.f11258 & (-225)) << 8) | c4140.m6702();
                    this.f11257 = iM67022;
                    C4140 c41402 = this.f11250;
                    byte[] bArr = c41402.f13227;
                    if (iM67022 > bArr.length) {
                        if (bArr.length < iM67022) {
                            bArr = new byte[iM67022];
                        }
                        c41402.m6684(bArr, iM67022);
                        C4139 c4139 = this.f11251;
                        byte[] bArr2 = this.f11250.f13227;
                        if (c4139 == null) {
                            throw null;
                        }
                        int length = bArr2.length;
                        c4139.f13223 = bArr2;
                        c4139.f13224 = 0;
                        c4139.f13225 = 0;
                        c4139.f13226 = length;
                    }
                    this.f11256 = 0;
                    this.f11255 = 3;
                } else {
                    if (i2 != 3) {
                        throw new IllegalStateException();
                    }
                    int iMin = Math.min(c4140.m6679(), this.f11257 - this.f11256);
                    c4140.m6685(this.f11251.f13223, this.f11256, iMin);
                    int i3 = this.f11256 + iMin;
                    this.f11256 = i3;
                    if (i3 == this.f11257) {
                        this.f11251.m6672(0);
                        C4139 c41392 = this.f11251;
                        if (c41392.m6677()) {
                            if (this.f11260) {
                            }
                            this.f11255 = 0;
                        } else {
                            this.f11260 = true;
                            int iM6667 = c41392.m6667(1);
                            int iM66672 = iM6667 == 1 ? c41392.m6667(1) : 0;
                            this.f11261 = iM66672;
                            if (iM66672 != 0) {
                                throw new ParserException();
                            }
                            if (iM6667 == 1) {
                                m6016(c41392);
                            }
                            if (!c41392.m6677()) {
                                throw new ParserException();
                            }
                            this.f11262 = c41392.m6667(6);
                            int iM66673 = c41392.m6667(4);
                            int iM66674 = c41392.m6667(3);
                            if (iM66673 != 0 || iM66674 != 0) {
                                throw new ParserException();
                            }
                            if (iM6667 == 0) {
                                int iM6676 = c41392.m6676();
                                int iM6017 = m6017(c41392);
                                c41392.m6672(iM6676);
                                byte[] bArr3 = new byte[(iM6017 + 7) / 8];
                                c41392.m6670(bArr3, 0, iM6017);
                                C3431 c3431M5585 = C3431.m5585(this.f11254, "audio/mp4a-latm", null, -1, -1, this.f11268, this.f11266, Collections.singletonList(bArr3), null, 0, this.f11249);
                                if (!c3431M5585.equals(this.f11253)) {
                                    this.f11253 = c3431M5585;
                                    this.f11267 = 1024000000 / ((long) c3431M5585.f10104);
                                    this.f11252.mo5884(c3431M5585);
                                }
                            } else {
                                c41392.m6675(((int) m6016(c41392)) - m6017(c41392));
                            }
                            int iM66675 = c41392.m6667(3);
                            this.f11263 = iM66675;
                            if (iM66675 == 0) {
                                c41392.m6675(8);
                            } else if (iM66675 == 1) {
                                c41392.m6675(9);
                            } else if (iM66675 == 3 || iM66675 == 4 || iM66675 == 5) {
                                c41392.m6675(6);
                            } else {
                                if (iM66675 != 6 && iM66675 != 7) {
                                    throw new IllegalStateException();
                                }
                                c41392.m6675(1);
                            }
                            boolean zM66772 = c41392.m6677();
                            this.f11264 = zM66772;
                            this.f11265 = 0L;
                            if (zM66772) {
                                if (iM6667 == 1) {
                                    this.f11265 = m6016(c41392);
                                } else {
                                    do {
                                        zM6677 = c41392.m6677();
                                        this.f11265 = (this.f11265 << 8) + ((long) c41392.m6667(8));
                                    } while (zM6677);
                                }
                            }
                            if (c41392.m6677()) {
                                c41392.m6675(8);
                            }
                        }
                        if (this.f11261 != 0) {
                            throw new ParserException();
                        }
                        if (this.f11262 != 0) {
                            throw new ParserException();
                        }
                        if (this.f11263 != 0) {
                            throw new ParserException();
                        }
                        int i4 = 0;
                        while (true) {
                            int iM66676 = c41392.m6667(8);
                            i = i4 + iM66676;
                            if (iM66676 != 255) {
                                break;
                            } else {
                                i4 = i;
                            }
                        }
                        int iM66762 = c41392.m6676();
                        if ((iM66762 & 7) == 0) {
                            this.f11250.m6693(iM66762 >> 3);
                        } else {
                            c41392.m6670(this.f11250.f13227, 0, i * 8);
                            this.f11250.m6693(0);
                        }
                        this.f11252.mo5885(this.f11250, i);
                        this.f11252.mo5883(this.f11259, 1, i, 0, null);
                        this.f11259 += this.f11267;
                        if (this.f11264) {
                            c41392.m6675((int) this.f11265);
                        }
                        this.f11255 = 0;
                    } else {
                        continue;
                    }
                }
            } else if (c4140.m6702() == 86) {
                this.f11255 = 1;
            }
        }
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ؠ */
    public void mo6001() {
    }
}
