package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.jj0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1601jj0 implements InterfaceC1219fj0 {
    public final HQ l;
    public final IQ m;
    public final int n;

    /* renamed from: o, reason: collision with root package name */
    public final InterfaceC0564Vt f598o;
    public int[] p = AbstractC1123ej0.a;
    public float[] q;
    public Y6 r;
    public Y6 s;
    public Y6 t;
    public Y6 u;
    public float[] v;
    public float[] w;
    public OD x;

    public C1601jj0(HQ hq, IQ iq, int i, InterfaceC0564Vt interfaceC0564Vt) {
        this.l = hq;
        this.m = iq;
        this.n = i;
        this.f598o = interfaceC0564Vt;
        float[] fArr = AbstractC1123ej0.b;
        this.q = fArr;
        this.v = fArr;
        this.w = fArr;
        this.x = AbstractC1123ej0.c;
    }

    public final int c(int i) {
        int i2;
        HQ hq = this.l;
        int i3 = hq.b;
        hq.getClass();
        if (i3 <= 0 || i3 > hq.b) {
            AbstractC2841wm0.J("");
            throw null;
        }
        int i4 = i3 - 1;
        int i5 = 0;
        while (true) {
            if (i5 <= i4) {
                i2 = (i5 + i4) >>> 1;
                int i6 = hq.a[i2];
                if (i6 >= i) {
                    if (i6 <= i) {
                        break;
                    }
                    i4 = i2 - 1;
                } else {
                    i5 = i2 + 1;
                }
            } else {
                i2 = -(i5 + 1);
                break;
            }
        }
        return i2 < -1 ? -(i2 + 2) : i2;
    }

    public final float d(int i, boolean z, int i2) {
        InterfaceC0564Vt interfaceC0564Vt;
        float f;
        HQ hq = this.l;
        if (i >= hq.b - 1) {
            f = i2;
        } else {
            int iC = hq.c(i);
            int iC2 = hq.c(i + 1);
            if (i2 == iC) {
                f = iC;
            } else {
                int i3 = iC2 - iC;
                C1506ij0 c1506ij0 = (C1506ij0) this.m.b(iC);
                if (c1506ij0 == null || (interfaceC0564Vt = c1506ij0.b) == null) {
                    interfaceC0564Vt = this.f598o;
                }
                float f2 = i3;
                float fA = interfaceC0564Vt.a((i2 - iC) / f2);
                if (z) {
                    return fA;
                }
                f = (f2 * fA) + iC;
            }
        }
        return f / 1000;
    }

    public final void e(Y6 y6, Y6 y62, Y6 y63) {
        float[] fArr;
        boolean z = this.x != AbstractC1123ej0.c;
        Y6 y64 = this.r;
        IQ iq = this.m;
        HQ hq = this.l;
        if (y64 == null) {
            this.r = y6.c();
            this.s = y63.c();
            int i = hq.b;
            float[] fArr2 = new float[i];
            for (int i2 = 0; i2 < i; i2++) {
                fArr2[i2] = hq.c(i2) / 1000;
            }
            this.q = fArr2;
            int i3 = hq.b;
            int[] iArr = new int[i3];
            for (int i4 = 0; i4 < i3; i4++) {
                iArr[i4] = 0;
            }
            this.p = iArr;
        }
        if (z) {
            if (this.x != AbstractC1123ej0.c && F3.c(this.t, y6) && F3.c(this.u, y62)) {
                return;
            }
            this.t = y6;
            this.u = y62;
            int iB = y6.b() + (y6.b() % 2);
            this.v = new float[iB];
            this.w = new float[iB];
            int i5 = hq.b;
            float[][] fArr3 = new float[i5][];
            for (int i6 = 0; i6 < i5; i6++) {
                int iC = hq.c(i6);
                C1506ij0 c1506ij0 = (C1506ij0) iq.b(iC);
                if (iC == 0 && c1506ij0 == null) {
                    fArr = new float[iB];
                    for (int i7 = 0; i7 < iB; i7++) {
                        fArr[i7] = y6.a(i7);
                    }
                } else if (iC == this.n && c1506ij0 == null) {
                    fArr = new float[iB];
                    for (int i8 = 0; i8 < iB; i8++) {
                        fArr[i8] = y62.a(i8);
                    }
                } else {
                    Y6 y65 = c1506ij0.a;
                    float[] fArr4 = new float[iB];
                    for (int i9 = 0; i9 < iB; i9++) {
                        fArr4[i9] = y65.a(i9);
                    }
                    fArr = fArr4;
                }
                fArr3[i6] = fArr;
            }
            this.x = new OD(this.p, this.q, fArr3);
        }
    }

    @Override // o.InterfaceC1219fj0
    public final int j() {
        return 0;
    }

    @Override // o.InterfaceC1028dj0
    public final Y6 l(long j, Y6 y6, Y6 y62, Y6 y63) {
        int[] iArr = AbstractC1123ej0.a;
        int i = 0;
        long j2 = (j / 1000000) - 0;
        long j3 = this.n;
        if (j2 < 0) {
            j2 = 0;
        }
        long j4 = j2 > j3 ? j3 : j2;
        if (j4 < 0) {
            return y63;
        }
        e(y6, y62, y63);
        Y6 y64 = this.s;
        if (this.x != AbstractC1123ej0.c) {
            int i2 = (int) j4;
            float fD = d(c(i2), false, i2);
            float[] fArr = this.w;
            U8[][] u8Arr = (U8[][]) this.x.m;
            float f = u8Arr[0][0].a;
            float f2 = u8Arr[u8Arr.length - 1][0].b;
            if (fD < f) {
                fD = f;
            }
            if (fD <= f2) {
                f2 = fD;
            }
            int length = fArr.length;
            boolean z = false;
            for (U8[] u8Arr2 : u8Arr) {
                int i3 = 0;
                int i4 = 0;
                while (i3 < length - 1) {
                    U8 u8 = u8Arr2[i4];
                    if (f2 <= u8.b) {
                        if (u8.p) {
                            fArr[i3] = u8.q;
                            fArr[i3 + 1] = u8.r;
                        } else {
                            u8.c(f2);
                            fArr[i3] = u8.a();
                            fArr[i3 + 1] = u8.b();
                        }
                        z = true;
                    }
                    i3 += 2;
                    i4++;
                }
                if (z) {
                    break;
                }
            }
            int length2 = fArr.length;
            while (i < length2) {
                y64.e(i, fArr[i]);
                i++;
            }
        } else {
            Y6 y6M = m((j4 - 1) * 1000000, y6, y62, y63);
            Y6 y6M2 = m(j4 * 1000000, y6, y62, y63);
            int iB = y6M.b();
            while (i < iB) {
                y64.e(i, (y6M.a(i) - y6M2.a(i)) * 1000.0f);
                i++;
            }
        }
        return y64;
    }

    @Override // o.InterfaceC1028dj0
    public final Y6 m(long j, Y6 y6, Y6 y62, Y6 y63) {
        Y6 y64;
        Y6 y65;
        float f;
        U8[][] u8Arr;
        boolean z;
        Y6 y66 = y6;
        Y6 y67 = y62;
        int[] iArr = AbstractC1123ej0.a;
        int i = 0;
        long j2 = (j / 1000000) - 0;
        int i2 = this.n;
        long j3 = i2;
        if (j2 < 0) {
            j2 = 0;
        }
        if (j2 <= j3) {
            j3 = j2;
        }
        int i3 = (int) j3;
        IQ iq = this.m;
        C1506ij0 c1506ij0 = (C1506ij0) iq.b(i3);
        if (c1506ij0 != null) {
            return c1506ij0.a;
        }
        if (i3 >= i2) {
            return y67;
        }
        if (i3 <= 0) {
            return y66;
        }
        e(y66, y67, y63);
        Y6 y68 = this.r;
        boolean z2 = true;
        if (this.x == AbstractC1123ej0.c) {
            int iC = c(i3);
            float fD = d(iC, true, i3);
            HQ hq = this.l;
            C1506ij0 c1506ij02 = (C1506ij0) iq.b(hq.c(iC));
            if (c1506ij02 != null && (y65 = c1506ij02.a) != null) {
                y66 = y65;
            }
            C1506ij0 c1506ij03 = (C1506ij0) iq.b(hq.c(iC + 1));
            if (c1506ij03 != null && (y64 = c1506ij03.a) != null) {
                y67 = y64;
            }
            int iB = y68.b();
            for (int i4 = 0; i4 < iB; i4++) {
                y68.e(i4, (y67.a(i4) * fD) + ((1 - fD) * y66.a(i4)));
            }
            return y68;
        }
        float fD2 = d(c(i3), false, i3);
        float[] fArr = this.v;
        U8[][] u8Arr2 = (U8[][]) this.x.m;
        int length = u8Arr2.length - 1;
        float f2 = u8Arr2[0][0].a;
        float f3 = u8Arr2[length][0].b;
        int length2 = fArr.length;
        if (fD2 < f2 || fD2 > f3) {
            if (fD2 > f3) {
                f2 = f3;
            } else {
                length = 0;
            }
            float f4 = fD2 - f2;
            int i5 = 0;
            int i6 = 0;
            while (i5 < length2 - 1) {
                U8 u8 = u8Arr2[length][i6];
                boolean z3 = u8.p;
                float f5 = u8.r;
                float f6 = u8.q;
                if (z3) {
                    float f7 = u8.a;
                    float f8 = u8.k;
                    f = f4;
                    float f9 = u8.c;
                    u8Arr = u8Arr2;
                    fArr[i5] = (f * f6) + AbstractC2462sn.f(u8.e, f9, (f2 - f7) * f8, f9);
                    float f10 = (f2 - f7) * f8;
                    float f11 = u8.d;
                    fArr[i5 + 1] = (f * f5) + AbstractC2462sn.f(u8.f, f11, f10, f11);
                } else {
                    f = f4;
                    u8Arr = u8Arr2;
                    u8.c(f2);
                    fArr[i5] = (u8.a() * f) + (u8.n * u8.h) + f6;
                    fArr[i5 + 1] = (u8.b() * f) + (u8.f353o * u8.i) + f5;
                }
                i5 += 2;
                i6++;
                f4 = f;
                u8Arr2 = u8Arr;
            }
        } else {
            int length3 = u8Arr2.length;
            int i7 = 0;
            boolean z4 = false;
            while (i7 < length3) {
                int i8 = i;
                int i9 = i8;
                while (i8 < length2 - 1) {
                    U8 u82 = u8Arr2[i7][i9];
                    if (fD2 <= u82.b) {
                        if (u82.p) {
                            float f12 = u82.a;
                            float f13 = u82.k;
                            float f14 = u82.c;
                            z = z2;
                            fArr[i8] = AbstractC2462sn.f(u82.e, f14, (fD2 - f12) * f13, f14);
                            float f15 = u82.d;
                            fArr[i8 + 1] = AbstractC2462sn.f(u82.f, f15, (fD2 - f12) * f13, f15);
                        } else {
                            z = z2;
                            u82.c(fD2);
                            fArr[i8] = (u82.n * u82.h) + u82.q;
                            fArr[i8 + 1] = (u82.f353o * u82.i) + u82.r;
                        }
                        z4 = z;
                    } else {
                        z = z2;
                    }
                    i8 += 2;
                    i9++;
                    z2 = z;
                }
                boolean z5 = z2;
                if (z4) {
                    break;
                }
                i7++;
                z2 = z5;
                i = 0;
            }
        }
        int length4 = fArr.length;
        for (int i10 = 0; i10 < length4; i10++) {
            y68.e(i10, fArr[i10]);
        }
        return y68;
    }

    @Override // o.InterfaceC1219fj0
    public final int o() {
        return this.n;
    }
}
