package defpackage;

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

/* renamed from: ﹶˈ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C5565 extends AbstractC1910 {

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final C1875 f20861;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final int f20862;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C3873 f20863;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public AbstractC3168 f20864;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final long f20865;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public int f20866;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public float f20867;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public long f20868;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final float f20869;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final float f20870;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final AbstractC2692 f20871;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final long f20872;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public int f20873;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final int f20874;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final long f20875;

    public C5565(C4010 c4010, int[] iArr, C3873 c3873, long j, long j2, long j3, float f, AbstractC2692 abstractC2692) {
        super(c4010, iArr);
        if (j3 < j) {
            ᵳʿˉ.ᵶʔᵢˊ("Adjusting minDurationToRetainAfterDiscardMs to be at least minDurationForQualityIncreaseMs");
            j3 = j;
        }
        this.f20863 = c3873;
        this.f20875 = j * 1000;
        this.f20865 = j2 * 1000;
        this.f20872 = j3 * 1000;
        this.f20874 = 1279;
        this.f20862 = 719;
        this.f20870 = 0.7f;
        this.f20869 = f;
        this.f20871 = AbstractC2692.m6700(abstractC2692);
        this.f20861 = C1875.f7592;
        this.f20867 = 1.0f;
        this.f20866 = 0;
        this.f20868 = -9223372036854775807L;
    }

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public static void m11202(ArrayList arrayList, long[] jArr) {
        long j = 0;
        for (long j2 : jArr) {
            j += j2;
        }
        for (int i = 0; i < arrayList.size(); i++) {
            C4704 c4704 = (C4704) arrayList.get(i);
            if (c4704 != null) {
                c4704.m3197(new C4721(j, jArr[i]));
            }
        }
    }

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public static long m11203(List list) {
        if (!list.isEmpty()) {
            AbstractC3168 abstractC3168 = (AbstractC3168) ᵯˉˋ.ᵨᵳʝ(list);
            long j = abstractC3168.f15959;
            if (j != -9223372036854775807L) {
                long j2 = abstractC3168.f15961;
                if (j2 != -9223372036854775807L) {
                    return j2 - j;
                }
            }
        }
        return -9223372036854775807L;
    }

    @Override // defpackage.InterfaceC5264
    /* renamed from: ˌʾˀ */
    public final int mo2645() {
        return this.f20866;
    }

    @Override // defpackage.InterfaceC5264
    /* renamed from: ˏᵙ */
    public final int mo2646() {
        return this.f20873;
    }

    @Override // defpackage.AbstractC1910, defpackage.InterfaceC5264
    /* renamed from: ᵝᵵᵺ */
    public final void mo5368() {
        this.f20868 = -9223372036854775807L;
        this.f20864 = null;
    }

    @Override // defpackage.AbstractC1910, defpackage.InterfaceC5264
    /* renamed from: ᵡʠ */
    public final void mo5370(float f) {
        this.f20867 = f;
    }

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final int m11204(long j) {
        long j2;
        C3873 c3873 = this.f20863;
        synchronized (c3873) {
            j2 = c3873.f14398;
        }
        long j3 = (long) (j2 * this.f20870);
        this.f20863.getClass();
        long j4 = (long) (j3 / this.f20867);
        if (!this.f20871.isEmpty()) {
            int i = 1;
            while (i < this.f20871.size() - 1 && ((C4721) this.f20871.get(i)).f17438 < j4) {
                i++;
            }
            C4721 c4721 = (C4721) this.f20871.get(i - 1);
            C4721 c47212 = (C4721) this.f20871.get(i);
            long j5 = c4721.f17438;
            long j6 = c4721.f17439;
            j4 = j6 + ((long) (((j4 - j5) / (c47212.f17438 - j5)) * (c47212.f17439 - j6)));
        }
        int i2 = 0;
        for (int i3 = 0; i3 < this.f7694; i3++) {
            if (j == Long.MIN_VALUE || !mo5363(j, i3)) {
                if (this.f7695[i3].f12932 <= j4) {
                    return i3;
                }
                i2 = i3;
            }
        }
        return i2;
    }

    @Override // defpackage.InterfaceC5264
    /* renamed from: ᵥᵯˎ */
    public final void mo2647(long j, long j2, long j3, List list, InterfaceC2379[] interfaceC2379Arr) {
        long jM11203;
        this.f20861.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        int i = this.f20873;
        if (i >= interfaceC2379Arr.length || !interfaceC2379Arr[i].next()) {
            int length = interfaceC2379Arr.length;
            int i2 = 0;
            while (true) {
                if (i2 >= length) {
                    jM11203 = m11203(list);
                    break;
                }
                InterfaceC2379 interfaceC2379 = interfaceC2379Arr[i2];
                if (interfaceC2379.next()) {
                    jM11203 = interfaceC2379.mo6147() - interfaceC2379.mo6148();
                    break;
                }
                i2++;
            }
        } else {
            InterfaceC2379 interfaceC23792 = interfaceC2379Arr[this.f20873];
            jM11203 = interfaceC23792.mo6147() - interfaceC23792.mo6148();
        }
        int i3 = this.f20866;
        if (i3 == 0) {
            this.f20866 = 1;
            this.f20873 = m11204(jElapsedRealtime);
            return;
        }
        int i4 = this.f20873;
        int iMo5379 = list.isEmpty() ? -1 : mo5379(((AbstractC3168) ᵯˉˋ.ᵨᵳʝ(list)).f15966);
        if (iMo5379 != -1) {
            i3 = ((AbstractC3168) ᵯˉˋ.ᵨᵳʝ(list)).f15964;
            i4 = iMo5379;
        }
        int iM11204 = m11204(jElapsedRealtime);
        if (iM11204 != i4 && !mo5363(jElapsedRealtime, i4)) {
            C3446[] c3446Arr = this.f7695;
            C3446 c3446 = c3446Arr[i4];
            C3446 c34462 = c3446Arr[iM11204];
            long jMin = this.f20875;
            if (j3 != -9223372036854775807L) {
                jMin = Math.min((long) ((jM11203 != -9223372036854775807L ? j3 - jM11203 : j3) * this.f20869), jMin);
            }
            int i5 = c34462.f12932;
            int i6 = c3446.f12932;
            if ((i5 > i6 && j2 < jMin) || (i5 < i6 && j2 >= this.f20865)) {
                iM11204 = i4;
            }
        }
        if (iM11204 != i4) {
            i3 = 3;
        }
        this.f20866 = i3;
        this.f20873 = iM11204;
    }

    @Override // defpackage.AbstractC1910, defpackage.InterfaceC5264
    /* renamed from: ᵯٴᵦ */
    public final void mo5373() {
        this.f20864 = null;
    }

    @Override // defpackage.InterfaceC5264
    /* renamed from: ᵸʓᵠ */
    public final Object mo2648() {
        return null;
    }

    @Override // defpackage.AbstractC1910, defpackage.InterfaceC5264
    /* renamed from: ᵸˑ */
    public final int mo5377(long j, List list) {
        int i;
        int i2;
        this.f20861.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        long j2 = this.f20868;
        if (j2 != -9223372036854775807L && jElapsedRealtime - j2 < 1000 && (list.isEmpty() || ((AbstractC3168) ᵯˉˋ.ᵨᵳʝ(list)).equals(this.f20864))) {
            return list.size();
        }
        this.f20868 = jElapsedRealtime;
        this.f20864 = list.isEmpty() ? null : (AbstractC3168) ᵯˉˋ.ᵨᵳʝ(list);
        if (list.isEmpty()) {
            return 0;
        }
        int size = list.size();
        long jM8155 = AbstractC3558.m8155(((AbstractC3168) list.get(size - 1)).f15959 - j, this.f20867);
        long j3 = this.f20872;
        if (jM8155 >= j3) {
            m11203(list);
            C3446 c3446 = this.f7695[m11204(jElapsedRealtime)];
            for (int i3 = 0; i3 < size; i3++) {
                AbstractC3168 abstractC3168 = (AbstractC3168) list.get(i3);
                C3446 c34462 = abstractC3168.f15966;
                if (AbstractC3558.m8155(abstractC3168.f15959 - j, this.f20867) >= j3 && c34462.f12932 < c3446.f12932 && (i = c34462.f12920) != -1 && i <= this.f20862 && (i2 = c34462.f12924) != -1 && i2 <= this.f20874 && i < c3446.f12920) {
                    return i3;
                }
            }
        }
        return size;
    }
}
