package defpackage;

import androidx.media3.common.ParserException;

/* JADX INFO: renamed from: ˁᵣˌ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0741 implements InterfaceC2750 {

    /* JADX INFO: renamed from: ˉᵲ, reason: contains not printable characters */
    public int f3332;

    /* JADX INFO: renamed from: ˊᵨᵧ, reason: contains not printable characters */
    public boolean f3334;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public int f3336;

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

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public int f3342;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public int f3343;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public int f3348;

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

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public InterfaceC5226 f3351;

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

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

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C3180 f3331 = new C3180(1);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C4545 f3338 = new C4545();

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final C1376 f3340 = new C1376();

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public int f3344 = -2147483647;

    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public int f3333 = -1;

    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public long f3337 = -1;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public boolean f3345 = true;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public boolean f3339 = true;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public double f3347 = -9.223372036854776E18d;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public double f3335 = -9.223372036854776E18d;

    @Override // defpackage.InterfaceC2750
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void mo2659() {
        this.f3349 = 0;
        this.f3343 = 0;
        this.f3346.m9603(2);
        this.f3336 = 0;
        this.f3342 = 0;
        this.f3344 = -2147483647;
        this.f3333 = -1;
        this.f3332 = 0;
        this.f3337 = -1L;
        this.f3334 = false;
        this.f3350 = false;
        this.f3339 = true;
        this.f3345 = true;
        this.f3347 = -9.223372036854776E18d;
        this.f3335 = -9.223372036854776E18d;
    }

    @Override // defpackage.InterfaceC2750
    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void mo2660(long j, int i) {
        this.f3348 = i;
        if (!this.f3345 && (this.f3342 != 0 || !this.f3339)) {
            this.f3350 = true;
        }
        if (j != -9223372036854775807L) {
            if (this.f3350) {
                this.f3335 = j;
            } else {
                this.f3347 = j;
            }
        }
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:155:0x02c0  */
    /* JADX WARN: Removed duplicated region for block: B:189:0x03ba  */
    /* JADX WARN: Removed duplicated region for block: B:212:0x041e  */
    @Override // defpackage.InterfaceC2750
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void mo2661(C4545 c4545) throws ParserException {
        int i;
        int i2;
        int iM7302;
        int iM73022;
        int i3;
        char c;
        byte[] bArr;
        long j;
        long j2;
        int iM73023;
        long j3;
        int i4;
        this.f3351.getClass();
        while (c4545.m9623() > 0) {
            int i5 = this.f3349;
            int i6 = 8;
            int i7 = 3;
            int i8 = 1;
            if (i5 != 0) {
                C4545 c45452 = this.f3338;
                C1376 c1376 = this.f3340;
                if (i5 == 1) {
                    int iM9623 = c4545.m9623();
                    C4545 c45453 = this.f3346;
                    int iMin = Math.min(iM9623, c45453.m9623());
                    c4545.m9627(c45453.f17284, c45453.f17282, iMin);
                    c45453.m9609(iMin);
                    if (c45453.m9623() == 0) {
                        int i9 = c45453.f17283;
                        byte[] bArr2 = c45453.f17284;
                        C3180 c3180 = this.f3331;
                        c3180.m7296(i9, bArr2);
                        c3180.m7305();
                        int iM2527 = AbstractC0702.m2527(c3180, 3, 8, 8);
                        c1376.f5709 = iM2527;
                        if (iM2527 != -1) {
                            ᵻᵪ.ᵱᵽʡᵚ(Math.max(Math.max(2, 8), 32) <= 63);
                            ᵥˈᵛ.ᵪᵹᵥᵻ(ᵥˈᵛ.ᵪᵹᵥᵻ(3L, 255L), 4294967296L);
                            if (c3180.m7286() < 2) {
                                j3 = -1;
                                c1376.f5708 = j3;
                                if (j3 != -1) {
                                    if (j3 > 16) {
                                        throw ParserException.m356("Contains sub-stream with an invalid packet label " + c1376.f5708);
                                    }
                                    if (j3 == 0) {
                                        int i10 = c1376.f5709;
                                        if (i10 == 1) {
                                            throw ParserException.m357("Mpegh3daConfig packet with invalid packet label 0", null);
                                        }
                                        if (i10 == 2) {
                                            throw ParserException.m357("Mpegh3daFrame packet with invalid packet label 0", null);
                                        }
                                        if (i10 == 17) {
                                            throw ParserException.m357("AudioTruncation packet with invalid packet label 0", null);
                                        }
                                    }
                                    int iM25272 = AbstractC0702.m2527(c3180, 11, 24, 24);
                                    c1376.f5710 = iM25272;
                                    boolean z = iM25272 != -1;
                                    if (z) {
                                        i4 = 0;
                                        this.f3336 = 0;
                                        this.f3342 = c1376.f5710 + i9 + this.f3342;
                                    } else {
                                        i4 = 0;
                                    }
                                    if (z) {
                                        c45453.m9624(i4);
                                        this.f3351.mo1740(c45453.f17283, c45453);
                                        c45453.m9603(2);
                                        c45452.m9603(c1376.f5710);
                                        this.f3339 = true;
                                        this.f3349 = 2;
                                    } else {
                                        int i11 = c45453.f17283;
                                        if (i11 < 15) {
                                            c45453.m9612(i11 + 1);
                                            this.f3339 = false;
                                        }
                                    }
                                }
                            } else {
                                long jM7293 = c3180.m7293(2);
                                if (jM7293 == 3) {
                                    if (c3180.m7286() >= 8) {
                                        long jM72932 = c3180.m7293(8);
                                        jM7293 += jM72932;
                                        if (jM72932 == 255) {
                                            if (c3180.m7286() >= 32) {
                                                jM7293 = c3180.m7293(32) + jM7293;
                                            }
                                        }
                                    }
                                    j3 = -1;
                                    c1376.f5708 = j3;
                                    if (j3 != -1) {
                                    }
                                }
                                j3 = jM7293;
                                c1376.f5708 = j3;
                                if (j3 != -1) {
                                }
                            }
                        }
                    } else {
                        this.f3339 = false;
                    }
                } else {
                    if (i5 != 2) {
                        ᵷᵝˎ.ᵱʡˏ();
                        return;
                    }
                    int i12 = c1376.f5709;
                    if (i12 == 1 || i12 == 17) {
                        int i13 = c4545.f17282;
                        int iMin2 = Math.min(c4545.m9623(), c45452.m9623());
                        c4545.m9627(c45452.f17284, c45452.f17282, iMin2);
                        c45452.m9609(iMin2);
                        c4545.m9624(i13);
                    }
                    int iMin3 = Math.min(c4545.m9623(), c1376.f5710 - this.f3336);
                    this.f3351.mo1740(iMin3, c4545);
                    int i14 = this.f3336 + iMin3;
                    this.f3336 = i14;
                    if (i14 != c1376.f5710) {
                        continue;
                    } else {
                        int i15 = c1376.f5709;
                        if (i15 == 1) {
                            byte[] bArr3 = c45452.f17284;
                            C3180 c31802 = new C3180(bArr3.length, bArr3);
                            int iM73024 = c31802.m7302(8);
                            int iM73025 = c31802.m7302(5);
                            if (iM73025 != 31) {
                                switch (iM73025) {
                                    case 0:
                                        iM73022 = 96000;
                                        break;
                                    case 1:
                                        iM73022 = 88200;
                                        break;
                                    case 2:
                                        iM73022 = 64000;
                                        break;
                                    case 3:
                                        iM73022 = 48000;
                                        break;
                                    case 4:
                                        iM73022 = 44100;
                                        break;
                                    case 5:
                                        iM73022 = 32000;
                                        break;
                                    case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                                        iM73022 = 24000;
                                        break;
                                    case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                                        iM73022 = 22050;
                                        break;
                                    case C5224.BYTES_FIELD_NUMBER /* 8 */:
                                        iM73022 = 16000;
                                        break;
                                    case 9:
                                        iM73022 = 12000;
                                        break;
                                    case 10:
                                        iM73022 = 11025;
                                        break;
                                    case 11:
                                        iM73022 = 8000;
                                        break;
                                    case 12:
                                        iM73022 = 7350;
                                        break;
                                    case 13:
                                    case 14:
                                    default:
                                        throw ParserException.m356("Unsupported sampling rate index " + iM73025);
                                    case 15:
                                        iM73022 = 57600;
                                        break;
                                    case 16:
                                        iM73022 = 51200;
                                        break;
                                    case 17:
                                        iM73022 = 40000;
                                        break;
                                    case 18:
                                        iM73022 = 38400;
                                        break;
                                    case 19:
                                        iM73022 = 34150;
                                        break;
                                    case 20:
                                        iM73022 = 28800;
                                        break;
                                    case 21:
                                        iM73022 = 25600;
                                        break;
                                    case 22:
                                        iM73022 = 20000;
                                        break;
                                    case 23:
                                        iM73022 = 19200;
                                        break;
                                    case 24:
                                        iM73022 = 17075;
                                        break;
                                    case 25:
                                        iM73022 = 14400;
                                        break;
                                    case 26:
                                        iM73022 = 12800;
                                        break;
                                    case 27:
                                        iM73022 = 9600;
                                        break;
                                }
                            } else {
                                iM73022 = c31802.m7302(24);
                            }
                            int iM73026 = c31802.m7302(3);
                            if (iM73026 == 0) {
                                i3 = 768;
                            } else if (iM73026 == 1) {
                                i3 = 1024;
                            } else if (iM73026 == 2 || iM73026 == 3) {
                                i3 = 2048;
                            } else {
                                if (iM73026 != 4) {
                                    throw ParserException.m356("Unsupported coreSbrFrameLengthIndex " + iM73026);
                                }
                                i3 = 4096;
                            }
                            int i16 = i3;
                            if (iM73026 == 0 || iM73026 == 1) {
                                c = 0;
                            } else if (iM73026 == 2) {
                                c = 2;
                            } else if (iM73026 == 3) {
                                c = 3;
                            } else {
                                if (iM73026 != 4) {
                                    throw ParserException.m356("Unsupported coreSbrFrameLengthIndex " + iM73026);
                                }
                                c = 1;
                            }
                            c31802.m7287(2);
                            AbstractC0702.m2537(c31802);
                            int iM73027 = c31802.m7302(5);
                            int i17 = 0;
                            int iM25273 = 0;
                            while (true) {
                                int i18 = i8;
                                int i19 = 16;
                                if (i17 < iM73027 + 1) {
                                    int iM73028 = c31802.m7302(3);
                                    iM25273 = AbstractC0702.m2527(c31802, 5, 8, 16) + 1 + iM25273;
                                    if ((iM73028 == 0 || iM73028 == 2) && c31802.m7299()) {
                                        AbstractC0702.m2537(c31802);
                                    }
                                    i17++;
                                    i8 = i18;
                                } else {
                                    int iM25274 = AbstractC0702.m2527(c31802, 4, 8, 16) + 1;
                                    c31802.m7288();
                                    int i20 = 0;
                                    while (true) {
                                        double d = 2.0d;
                                        if (i20 < iM25274) {
                                            int iM73029 = c31802.m7302(2);
                                            if (iM73029 == 0) {
                                                c31802.m7287(i7);
                                                if (c31802.m7299()) {
                                                    c31802.m7287(13);
                                                }
                                                if (c > 0) {
                                                    AbstractC0702.m2534(c31802);
                                                }
                                            } else if (iM73029 == i18) {
                                                c31802.m7287(i7);
                                                boolean zM7299 = c31802.m7299();
                                                if (zM7299) {
                                                    c31802.m7287(13);
                                                }
                                                if (zM7299) {
                                                    c31802.m7288();
                                                }
                                                if (c > 0) {
                                                    AbstractC0702.m2534(c31802);
                                                    iM73023 = c31802.m7302(2);
                                                } else {
                                                    iM73023 = 0;
                                                }
                                                if (iM73023 > 0) {
                                                    c31802.m7287(6);
                                                    int iM730210 = c31802.m7302(2);
                                                    c31802.m7287(4);
                                                    if (c31802.m7299()) {
                                                        c31802.m7287(5);
                                                    }
                                                    if (iM73023 == 2 || iM73023 == i7) {
                                                        c31802.m7287(6);
                                                    }
                                                    if (iM730210 == 2) {
                                                        c31802.m7288();
                                                    }
                                                }
                                                int iFloor = ((int) Math.floor(Math.log(iM25273 - 1) / Math.log(2.0d))) + 1;
                                                int iM730211 = c31802.m7302(2);
                                                if (iM730211 > 0 && c31802.m7299()) {
                                                    c31802.m7287(iFloor);
                                                }
                                                if (c31802.m7299()) {
                                                    c31802.m7287(iFloor);
                                                }
                                                if (c == 0 && iM730211 == 0) {
                                                    c31802.m7288();
                                                }
                                            } else if (iM73029 == i7) {
                                                AbstractC0702.m2527(c31802, 4, i6, i19);
                                                int iM25275 = AbstractC0702.m2527(c31802, 4, i6, i19);
                                                if (c31802.m7299()) {
                                                    AbstractC0702.m2527(c31802, i6, i19, 0);
                                                }
                                                c31802.m7288();
                                                if (iM25275 > 0) {
                                                    c31802.m7287(iM25275 * 8);
                                                }
                                            }
                                            i20++;
                                            i6 = 8;
                                            i7 = 3;
                                            i19 = 16;
                                            i18 = 1;
                                        } else {
                                            if (c31802.m7299()) {
                                                int i21 = 8;
                                                int iM25276 = AbstractC0702.m2527(c31802, 2, 4, 8) + 1;
                                                int i22 = 0;
                                                bArr = null;
                                                while (i22 < iM25276) {
                                                    int iM25277 = AbstractC0702.m2527(c31802, 4, i21, 16);
                                                    int iM25278 = AbstractC0702.m2527(c31802, 4, i21, 16);
                                                    if (iM25277 == 7) {
                                                        int iM730212 = c31802.m7302(4) + 1;
                                                        c31802.m7287(4);
                                                        byte[] bArr4 = new byte[iM730212];
                                                        for (int i23 = 0; i23 < iM730212; i23++) {
                                                            bArr4[i23] = (byte) c31802.m7302(i21);
                                                        }
                                                        bArr = bArr4;
                                                    } else {
                                                        c31802.m7287(iM25278 * i21);
                                                    }
                                                    i22++;
                                                    i21 = 8;
                                                }
                                            } else {
                                                bArr = null;
                                            }
                                            switch (iM73022) {
                                                case 14700:
                                                case 16000:
                                                    d = 3.0d;
                                                    this.f3344 = (int) (((double) iM73022) * d);
                                                    this.f3333 = (int) (((double) i16) * d);
                                                    j = this.f3337;
                                                    j2 = c1376.f5708;
                                                    if (j != j2) {
                                                        this.f3337 = j2;
                                                        String strConcat = iM73024 != -1 ? "mhm1".concat(String.format(".%02X", Integer.valueOf(iM73024))) : "mhm1";
                                                        C2598 c2598M9557 = (bArr == null || bArr.length <= 0) ? null : AbstractC4509.m9557(AbstractC0956.f4216, bArr);
                                                        C4753 c4753 = new C4753();
                                                        c4753.f18121 = this.f3341;
                                                        c4753.f18111 = AbstractC4208.m9132("video/mp2t");
                                                        c4753.f18101 = AbstractC4208.m9132("audio/mhm1");
                                                        c4753.f18113 = this.f3344;
                                                        c4753.f18120 = strConcat;
                                                        c4753.f18119 = c2598M9557;
                                                        this.f3351.mo1742(new C5286(c4753));
                                                    }
                                                    i2 = 1;
                                                    this.f3334 = true;
                                                    break;
                                                case 22050:
                                                case 24000:
                                                    this.f3344 = (int) (((double) iM73022) * d);
                                                    this.f3333 = (int) (((double) i16) * d);
                                                    j = this.f3337;
                                                    j2 = c1376.f5708;
                                                    if (j != j2) {
                                                    }
                                                    i2 = 1;
                                                    this.f3334 = true;
                                                    break;
                                                case 29400:
                                                case 32000:
                                                case 58800:
                                                case 64000:
                                                    d = 1.5d;
                                                    this.f3344 = (int) (((double) iM73022) * d);
                                                    this.f3333 = (int) (((double) i16) * d);
                                                    j = this.f3337;
                                                    j2 = c1376.f5708;
                                                    if (j != j2) {
                                                    }
                                                    i2 = 1;
                                                    this.f3334 = true;
                                                    break;
                                                case 44100:
                                                case 48000:
                                                case 88200:
                                                case 96000:
                                                    d = 1.0d;
                                                    this.f3344 = (int) (((double) iM73022) * d);
                                                    this.f3333 = (int) (((double) i16) * d);
                                                    j = this.f3337;
                                                    j2 = c1376.f5708;
                                                    if (j != j2) {
                                                    }
                                                    i2 = 1;
                                                    this.f3334 = true;
                                                    break;
                                                default:
                                                    throw ParserException.m356("Unsupported sampling rate " + iM73022);
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            if (i15 == 17) {
                                byte[] bArr5 = c45452.f17284;
                                C3180 c31803 = new C3180(bArr5.length, bArr5);
                                if (c31803.m7299()) {
                                    c31803.m7287(2);
                                    iM7302 = c31803.m7302(13);
                                } else {
                                    iM7302 = 0;
                                }
                                this.f3332 = iM7302;
                            } else if (i15 == 2) {
                                if (this.f3334) {
                                    this.f3345 = false;
                                    i = 1;
                                } else {
                                    i = 0;
                                }
                                double d2 = (((double) (this.f3333 - this.f3332)) * 1000000.0d) / ((double) this.f3344);
                                long jRound = Math.round(this.f3347);
                                if (this.f3350) {
                                    this.f3350 = false;
                                    this.f3347 = this.f3335;
                                } else {
                                    this.f3347 += d2;
                                }
                                this.f3351.mo1741(jRound, i, this.f3342, 0, null);
                                this.f3334 = false;
                                this.f3332 = 0;
                                this.f3342 = 0;
                            }
                            i2 = 1;
                        }
                        this.f3349 = i2;
                    }
                }
            } else {
                int i24 = this.f3348;
                if ((i24 & 2) == 0) {
                    c4545.m9624(c4545.f17283);
                } else {
                    if ((i24 & 4) == 0) {
                        while (c4545.m9623() > 0) {
                            int i25 = this.f3343 << 8;
                            this.f3343 = i25;
                            int iM9626 = i25 | c4545.m9626();
                            this.f3343 = iM9626;
                            if ((iM9626 & 16777215) == 12583333) {
                                c4545.m9624(c4545.f17282 - 3);
                                this.f3343 = 0;
                            }
                        }
                    }
                    this.f3349 = 1;
                }
            }
        }
    }

    @Override // defpackage.InterfaceC2750
    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void mo2662(boolean z) {
    }

    @Override // defpackage.InterfaceC2750
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void mo2663(InterfaceC4550 interfaceC4550, C4173 c4173) {
        c4173.m9112();
        c4173.m9111();
        this.f3341 = c4173.f15926;
        c4173.m9111();
        this.f3351 = interfaceC4550.mo2743(c4173.f15928, 1);
    }
}
