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

import android.util.Log;
import android.util.Pair;
import java.util.Arrays;
import java.util.Collections;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p194.C3526;
import p138.p176.p177.p190.p198.C3560;
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 C3656 implements InterfaceC3660 {

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public static final byte[] f11104 = {73, 68, 51};

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

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

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C4140 f11107 = new C4140(Arrays.copyOf(f11104, 10));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public C3656(boolean z, String str) {
        m6006();
        this.f11117 = -1;
        this.f11118 = -1;
        this.f11121 = -9223372036854775807L;
        this.f11105 = z;
        this.f11108 = str;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m6003(int i) {
        return (i & 65526) == 65520;
    }

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

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

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5999(InterfaceC3562 interfaceC3562, InterfaceC3690.C3694 c3694) {
        c3694.m6035();
        this.f11109 = c3694.m6036();
        this.f11110 = interfaceC3562.mo5891(c3694.m6037(), 1);
        if (!this.f11105) {
            this.f11111 = new C3560();
            return;
        }
        c3694.m6035();
        InterfaceC3575 interfaceC3575Mo5891 = interfaceC3562.mo5891(c3694.m6037(), 4);
        this.f11111 = interfaceC3575Mo5891;
        interfaceC3575Mo5891.mo5884(C3431.m5589(c3694.m6036(), "application/id3", (String) null, -1, (C3526) null));
    }

    /* JADX WARN: Code restructure failed: missing block: B:108:0x024b, code lost:
    
        r23.f11119 = (r11 & 8) >> 3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:109:0x0252, code lost:
    
        if ((r11 & 1) != 0) goto L111;
     */
    /* JADX WARN: Code restructure failed: missing block: B:110:0x0254, code lost:
    
        r2 = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:111:0x0256, code lost:
    
        r2 = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:112:0x0257, code lost:
    
        r23.f11115 = r2;
     */
    /* JADX WARN: Code restructure failed: missing block: B:113:0x025b, code lost:
    
        if (r23.f11116 != false) goto L115;
     */
    /* JADX WARN: Code restructure failed: missing block: B:114:0x025d, code lost:
    
        r23.f11112 = 1;
        r23.f11113 = 0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:115:0x0263, code lost:
    
        r23.f11112 = 3;
        r23.f11113 = 0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:116:0x0268, code lost:
    
        r24.m6693(r13);
     */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0248  */
    /* JADX WARN: Removed duplicated region for block: B:119:0x0275  */
    /* JADX WARN: Removed duplicated region for block: B:132:0x02b3  */
    /* JADX WARN: Removed duplicated region for block: B:157:0x024b A[EDGE_INSN: B:157:0x024b->B:108:0x024b BREAK  A[LOOP:1: B:49:0x017c->B:134:0x02ba], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:75:0x01f3  */
    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo6000(C4140 c4140) {
        int i;
        boolean z;
        int i2;
        int i3;
        int i4;
        while (c4140.m6679() > 0) {
            int i5 = this.f11112;
            int i6 = 2;
            if (i5 == 0) {
                byte[] bArr = c4140.f13227;
                int i7 = c4140.f13228;
                int i8 = c4140.f13229;
                while (true) {
                    if (i7 >= i8) {
                        c4140.m6693(i7);
                        break;
                    }
                    int i9 = i7 + 1;
                    int i10 = bArr[i7] & 255;
                    if (this.f11114 != 512 || !m6003((((byte) i10) & 255) | 65280)) {
                        int i11 = this.f11114;
                        i = i10 | i11;
                        if (i == 329) {
                            this.f11114 = 768;
                        } else if (i == 511) {
                            this.f11114 = 512;
                        } else if (i == 836) {
                            this.f11114 = 1024;
                        } else {
                            if (i == 1075) {
                                this.f11112 = 2;
                                this.f11113 = f11104.length;
                                this.f11122 = 0;
                                this.f11107.m6693(0);
                                c4140.m6693(i9);
                                break;
                            }
                            if (i11 != 256) {
                                this.f11114 = 256;
                                i7 = i9 - 1;
                                i = 7;
                                i6 = 2;
                            }
                        }
                        i7 = i9;
                        i = 7;
                        i6 = 2;
                    } else {
                        if (this.f11116) {
                            break;
                        }
                        int i12 = i9 - 2;
                        c4140.m6693(i12 + 1);
                        if (m6005(c4140, this.f11106.f13223, 1)) {
                            this.f11106.m6672(4);
                            int iM6667 = this.f11106.m6667(1);
                            int i13 = this.f11117;
                            if (i13 == -1 || iM6667 == i13) {
                                if (this.f11118 == -1) {
                                    if (m6005(c4140, this.f11106.f13223, 4)) {
                                        this.f11106.m6672(14);
                                        int iM66672 = this.f11106.m6667(13);
                                        if (iM66672 >= i) {
                                            byte[] bArr2 = c4140.f13227;
                                            int i14 = c4140.f13229;
                                            int i15 = i12 + iM66672;
                                            if (i15 < i14 && (bArr2[i15] != -1 ? !(bArr2[i15] == 73 && ((i2 = i15 + 1) == i14 || (bArr2[i2] == 68 && ((i3 = i15 + 2) == i14 || bArr2[i3] == 51)))) : !((i4 = i15 + 1) == i14 || (m6003((bArr2[i4] & 255) | 65280) && ((bArr2[i4] & 8) >> 3) == iM6667)))) {
                                            }
                                            if (z) {
                                            }
                                            int i112 = this.f11114;
                                            i = i10 | i112;
                                            if (i == 329) {
                                            }
                                            i7 = i9;
                                            i = 7;
                                            i6 = 2;
                                        }
                                        z = false;
                                        if (z) {
                                        }
                                        int i1122 = this.f11114;
                                        i = i10 | i1122;
                                        if (i == 329) {
                                        }
                                        i7 = i9;
                                        i = 7;
                                        i6 = 2;
                                    }
                                    z = true;
                                    if (z) {
                                    }
                                    int i11222 = this.f11114;
                                    i = i10 | i11222;
                                    if (i == 329) {
                                    }
                                    i7 = i9;
                                    i = 7;
                                    i6 = 2;
                                } else {
                                    if (m6005(c4140, this.f11106.f13223, 1)) {
                                        this.f11106.m6672(i6);
                                        if (this.f11106.m6667(4) == this.f11118) {
                                            c4140.m6693(i12 + 2);
                                            if (m6005(c4140, this.f11106.f13223, 4)) {
                                            }
                                        }
                                        z = false;
                                        if (z) {
                                        }
                                        int i112222 = this.f11114;
                                        i = i10 | i112222;
                                        if (i == 329) {
                                        }
                                        i7 = i9;
                                        i = 7;
                                        i6 = 2;
                                    }
                                    z = true;
                                    if (z) {
                                    }
                                    int i1122222 = this.f11114;
                                    i = i10 | i1122222;
                                    if (i == 329) {
                                    }
                                    i7 = i9;
                                    i = 7;
                                    i6 = 2;
                                }
                            }
                        } else {
                            z = false;
                            if (z) {
                                break;
                            }
                            int i11222222 = this.f11114;
                            i = i10 | i11222222;
                            if (i == 329) {
                            }
                            i7 = i9;
                            i = 7;
                            i6 = 2;
                        }
                    }
                }
            } else if (i5 != 1) {
                if (i5 != 2) {
                    if (i5 == 3) {
                        if (m6004(c4140, this.f11106.f13223, this.f11115 ? 7 : 5)) {
                            this.f11106.m6672(0);
                            if (this.f11120) {
                                this.f11106.m6675(10);
                            } else {
                                int iM66673 = this.f11106.m6667(2) + 1;
                                if (iM66673 != 2) {
                                    Log.w("AdtsReader", "Detected audio object type: " + iM66673 + ", but assuming AAC LC.");
                                    iM66673 = 2;
                                }
                                this.f11106.m6675(5);
                                byte[] bArrM6624 = C4121.m6624(iM66673, this.f11118, this.f11106.m6667(3));
                                Pair<Integer, Integer> pairM6622 = C4121.m6622(bArrM6624);
                                C3431 c3431M5585 = C3431.m5585(this.f11109, "audio/mp4a-latm", null, -1, -1, ((Integer) pairM6622.second).intValue(), ((Integer) pairM6622.first).intValue(), Collections.singletonList(bArrM6624), null, 0, this.f11108);
                                this.f11121 = 1024000000 / ((long) c3431M5585.f10104);
                                this.f11110.mo5884(c3431M5585);
                                this.f11120 = true;
                            }
                            this.f11106.m6675(4);
                            int iM66674 = (this.f11106.m6667(13) - 2) - 5;
                            if (this.f11115) {
                                iM66674 -= 2;
                            }
                            InterfaceC3575 interfaceC3575 = this.f11110;
                            long j = this.f11121;
                            this.f11112 = 4;
                            this.f11113 = 0;
                            this.f11124 = interfaceC3575;
                            this.f11125 = j;
                            this.f11122 = iM66674;
                        }
                    } else {
                        if (i5 != 4) {
                            throw new IllegalStateException();
                        }
                        int iMin = Math.min(c4140.m6679(), this.f11122 - this.f11113);
                        this.f11124.mo5885(c4140, iMin);
                        int i16 = this.f11113 + iMin;
                        this.f11113 = i16;
                        int i17 = this.f11122;
                        if (i16 == i17) {
                            this.f11124.mo5883(this.f11123, 1, i17, 0, null);
                            this.f11123 += this.f11125;
                            m6006();
                        }
                    }
                } else if (m6004(c4140, this.f11107.f13227, 10)) {
                    this.f11111.mo5885(this.f11107, 10);
                    this.f11107.m6693(6);
                    InterfaceC3575 interfaceC35752 = this.f11111;
                    int iM6701 = this.f11107.m6701() + 10;
                    this.f11112 = 4;
                    this.f11113 = 10;
                    this.f11124 = interfaceC35752;
                    this.f11125 = 0L;
                    this.f11122 = iM6701;
                }
            } else if (c4140.m6679() != 0) {
                C4139 c4139 = this.f11106;
                c4139.f13223[0] = c4140.f13227[c4140.f13228];
                c4139.m6672(2);
                int iM66675 = this.f11106.m6667(4);
                int i18 = this.f11118;
                if (i18 == -1 || iM66675 == i18) {
                    if (!this.f11116) {
                        this.f11116 = true;
                        this.f11117 = this.f11119;
                        this.f11118 = iM66675;
                    }
                    this.f11112 = 3;
                    this.f11113 = 0;
                } else {
                    this.f11116 = false;
                    m6006();
                }
            }
        }
    }

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

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

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m6005(C4140 c4140, byte[] bArr, int i) {
        if (c4140.m6679() < i) {
            return false;
        }
        System.arraycopy(c4140.f13227, c4140.f13228, bArr, 0, i);
        c4140.f13228 += i;
        return true;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void m6006() {
        this.f11112 = 0;
        this.f11113 = 0;
        this.f11114 = 256;
    }
}
