package defpackage;

import android.os.SystemClock;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: renamed from: ˏـˎᵚ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1861 extends AbstractC2354 {

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

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

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

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final long f7358;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public final float f7359;

    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public long f7360;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public final float f7361;

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final C2353 f7362;

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public final AbstractC4509 f7363;

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

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public float f7365;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final long f7366;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C4216 f7367;

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

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final long f7369;

    public C1861(C1882 c1882, int[] iArr, C4216 c4216, long j, long j2, long j3, float f, AbstractC4509 abstractC4509) {
        super(c1882, iArr);
        if (j3 < j) {
            ˋˀᵧ.ʿٴˇ("Adjusting minDurationToRetainAfterDiscardMs to be at least minDurationForQualityIncreaseMs");
            j3 = j;
        }
        this.f7367 = c4216;
        this.f7358 = j * 1000;
        this.f7369 = j2 * 1000;
        this.f7366 = j3 * 1000;
        this.f7368 = 1279;
        this.f7364 = 719;
        this.f7361 = 0.7f;
        this.f7359 = f;
        this.f7363 = AbstractC4509.m9559(abstractC4509);
        this.f7362 = C2353.f9226;
        this.f7365 = 1.0f;
        this.f7355 = 0;
        this.f7360 = -9223372036854775807L;
    }

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public static void m5054(ArrayList arrayList, long[] jArr) {
        long j = 0;
        for (long j2 : jArr) {
            j += j2;
        }
        for (int i = 0; i < arrayList.size(); i++) {
            C3975 c3975 = (C3975) arrayList.get(i);
            if (c3975 != null) {
                c3975.m7406(new C5328(j, jArr[i]));
            }
        }
    }

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public static long m5055(List list) {
        if (!list.isEmpty()) {
            AbstractC4352 abstractC4352 = (AbstractC4352) ᵸᵺᵜ.ˊᵙᵾᵲ(list);
            long j = abstractC4352.f7526;
            if (j != -9223372036854775807L) {
                long j2 = abstractC4352.f7528;
                if (j2 != -9223372036854775807L) {
                    return j2 - j;
                }
            }
        }
        return -9223372036854775807L;
    }

    @Override // defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ˊᵙᵾᵲ */
    public final Object mo3507() {
        return null;
    }

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

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final int m5056(long j) {
        long j2;
        C4216 c4216 = this.f7367;
        synchronized (c4216) {
            j2 = c4216.f16052;
        }
        long j3 = (long) (j2 * this.f7361);
        this.f7367.getClass();
        long j4 = (long) (j3 / this.f7365);
        if (!this.f7363.isEmpty()) {
            int i = 1;
            while (i < this.f7363.size() - 1 && ((C5328) this.f7363.get(i)).f20088 < j4) {
                i++;
            }
            C5328 c5328 = (C5328) this.f7363.get(i - 1);
            C5328 c53282 = (C5328) this.f7363.get(i);
            long j5 = c5328.f20088;
            long j6 = c5328.f20087;
            j4 = j6 + ((long) (((j4 - j5) / (c53282.f20088 - j5)) * (c53282.f20087 - j6)));
        }
        int i2 = 0;
        for (int i3 = 0; i3 < this.f9227; i3++) {
            if (j == Long.MIN_VALUE || !mo3737(j, i3)) {
                if (this.f9231[i3].f19991 <= j4) {
                    return i3;
                }
                i2 = i3;
            }
        }
        return i2;
    }

    @Override // defpackage.AbstractC2354, defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵝᵶ */
    public final void mo3736() {
        this.f7357 = null;
    }

    @Override // defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵟᵹᵙ */
    public final int mo3509() {
        return this.f7355;
    }

    @Override // defpackage.AbstractC2354, defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵱʡˏ */
    public final void mo3740(float f) {
        this.f7365 = f;
    }

    @Override // defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo3510(long j, long j2, long j3, List list, InterfaceC2178[] interfaceC2178Arr) {
        long jM5055;
        this.f7362.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        int i = this.f7356;
        if (i >= interfaceC2178Arr.length || !interfaceC2178Arr[i].next()) {
            int length = interfaceC2178Arr.length;
            int i2 = 0;
            while (true) {
                if (i2 >= length) {
                    jM5055 = m5055(list);
                    break;
                }
                InterfaceC2178 interfaceC2178 = interfaceC2178Arr[i2];
                if (interfaceC2178.next()) {
                    jM5055 = interfaceC2178.mo5688() - interfaceC2178.mo5687();
                    break;
                }
                i2++;
            }
        } else {
            InterfaceC2178 interfaceC21782 = interfaceC2178Arr[this.f7356];
            jM5055 = interfaceC21782.mo5688() - interfaceC21782.mo5687();
        }
        int i3 = this.f7355;
        if (i3 == 0) {
            this.f7355 = 1;
            this.f7356 = m5056(jElapsedRealtime);
            return;
        }
        int i4 = this.f7356;
        int iMo3744 = list.isEmpty() ? -1 : mo3744(((AbstractC4352) ᵸᵺᵜ.ˊᵙᵾᵲ(list)).f7531);
        if (iMo3744 != -1) {
            i3 = ((AbstractC4352) ᵸᵺᵜ.ˊᵙᵾᵲ(list)).f7532;
            i4 = iMo3744;
        }
        int iM5056 = m5056(jElapsedRealtime);
        if (iM5056 != i4 && !mo3737(jElapsedRealtime, i4)) {
            C5286[] c5286Arr = this.f9231;
            C5286 c5286 = c5286Arr[i4];
            C5286 c52862 = c5286Arr[iM5056];
            long jMin = this.f7358;
            if (j3 != -9223372036854775807L) {
                jMin = Math.min((long) ((jM5055 != -9223372036854775807L ? j3 - jM5055 : j3) * this.f7359), jMin);
            }
            int i5 = c52862.f19991;
            int i6 = c5286.f19991;
            if ((i5 > i6 && j2 < jMin) || (i5 < i6 && j2 >= this.f7369)) {
                iM5056 = i4;
            }
        }
        if (iM5056 != i4) {
            i3 = 3;
        }
        this.f7355 = i3;
        this.f7356 = iM5056;
    }

    @Override // defpackage.AbstractC2354, defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵶᵥᵝ */
    public final int mo3743(long j, List list) {
        int i;
        int i2;
        this.f7362.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        long j2 = this.f7360;
        if (j2 != -9223372036854775807L && jElapsedRealtime - j2 < 1000 && (list.isEmpty() || ((AbstractC4352) ᵸᵺᵜ.ˊᵙᵾᵲ(list)).equals(this.f7357))) {
            return list.size();
        }
        this.f7360 = jElapsedRealtime;
        this.f7357 = list.isEmpty() ? null : (AbstractC4352) ᵸᵺᵜ.ˊᵙᵾᵲ(list);
        if (list.isEmpty()) {
            return 0;
        }
        int size = list.size();
        long jM3223 = AbstractC0956.m3223(((AbstractC4352) list.get(size - 1)).f7526 - j, this.f7365);
        long j3 = this.f7366;
        if (jM3223 >= j3) {
            m5055(list);
            C5286 c5286 = this.f9231[m5056(jElapsedRealtime)];
            for (int i3 = 0; i3 < size; i3++) {
                AbstractC4352 abstractC4352 = (AbstractC4352) list.get(i3);
                C5286 c52862 = abstractC4352.f7531;
                if (AbstractC0956.m3223(abstractC4352.f7526 - j, this.f7365) >= j3 && c52862.f19991 < c5286.f19991 && (i = c52862.f19981) != -1 && i <= this.f7364 && (i2 = c52862.f19973) != -1 && i2 <= this.f7368 && i < c5286.f19981) {
                    return i3;
                }
            }
        }
        return size;
    }

    @Override // defpackage.AbstractC2354, defpackage.InterfaceC2380
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final void mo3745() {
        this.f7360 = -9223372036854775807L;
        this.f7357 = null;
    }
}
