package p138.p176.p177.p190.p192;

import java.util.Arrays;
import p000.p001.p002.p003.p004.C0567;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ࢪ.ޖ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3502 {

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

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int f10400;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final float f10401;

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

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final float f10403;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int f10404;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final int f10405;

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

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final short[] f10407;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public short[] f10408;

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

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public short[] f10410;

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

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public short[] f10412;

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

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

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

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

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

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

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

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

    public C3502(int i, int i2, float f, float f2, int i3) {
        this.f10399 = i;
        this.f10400 = i2;
        this.f10401 = f;
        this.f10402 = f2;
        this.f10403 = i / i3;
        this.f10404 = i / 400;
        int i4 = i / 65;
        this.f10405 = i4;
        int i5 = i4 * 2;
        this.f10406 = i5;
        this.f10407 = new short[i5];
        this.f10408 = new short[i5 * i2];
        this.f10410 = new short[i5 * i2];
        this.f10412 = new short[i5 * i2];
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m5795(int i, int i2, short[] sArr, int i3, short[] sArr2, int i4, short[] sArr3, int i5) {
        for (int i6 = 0; i6 < i2; i6++) {
            int i7 = (i3 * i2) + i6;
            int i8 = (i5 * i2) + i6;
            int i9 = (i4 * i2) + i6;
            for (int i10 = 0; i10 < i; i10++) {
                sArr[i7] = (short) (((sArr3[i8] * i10) + ((i - i10) * sArr2[i9])) / i);
                i7 += i2;
                i9 += i2;
                i8 += i2;
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m5796(short[] sArr, int i, int i2, int i3) {
        int i4 = i * this.f10400;
        int i5 = 1;
        int i6 = 255;
        int i7 = 0;
        int i8 = 0;
        while (i2 <= i3) {
            int iAbs = 0;
            for (int i9 = 0; i9 < i2; i9++) {
                iAbs += Math.abs(sArr[i4 + i9] - sArr[(i4 + i2) + i9]);
            }
            if (iAbs * i7 < i5 * i2) {
                i7 = i2;
                i5 = iAbs;
            }
            if (iAbs * i6 > i8 * i2) {
                i6 = i2;
                i8 = iAbs;
            }
            i2++;
        }
        this.f10419 = i5 / i7;
        this.f10420 = i8 / i6;
        return i7;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m5797() {
        int iM5796;
        int i;
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        int i7 = this.f10411;
        float f = this.f10401;
        float f2 = this.f10402;
        float f3 = f / f2;
        float f4 = this.f10403 * f2;
        double d = f3;
        float f5 = 1.0f;
        int i8 = 1;
        if (d > 1.00001d || d < 0.99999d) {
            int i9 = this.f10409;
            if (i9 >= this.f10406) {
                int i10 = 0;
                while (true) {
                    int i11 = this.f10416;
                    if (i11 > 0) {
                        int iMin = Math.min(this.f10406, i11);
                        m5798(this.f10408, i10, iMin);
                        this.f10416 -= iMin;
                        i10 += iMin;
                    } else {
                        short[] sArr = this.f10408;
                        int i12 = this.f10399;
                        int i13 = i12 > 4000 ? i12 / 4000 : 1;
                        if (this.f10400 == i8 && i13 == i8) {
                            iM5796 = m5796(sArr, i10, this.f10404, this.f10405);
                        } else {
                            m5799(sArr, i10, i13);
                            int iM57962 = m5796(this.f10407, 0, this.f10404 / i13, this.f10405 / i13);
                            if (i13 != i8) {
                                int i14 = iM57962 * i13;
                                int i15 = i13 * 4;
                                int i16 = i14 - i15;
                                int i17 = i14 + i15;
                                int i18 = this.f10404;
                                if (i16 < i18) {
                                    i16 = i18;
                                }
                                int i19 = this.f10405;
                                if (i17 > i19) {
                                    i17 = i19;
                                }
                                if (this.f10400 == i8) {
                                    iM5796 = m5796(sArr, i10, i16, i17);
                                } else {
                                    m5799(sArr, i10, i8);
                                    iM5796 = m5796(this.f10407, 0, i16, i17);
                                }
                            } else {
                                iM5796 = iM57962;
                            }
                        }
                        int i20 = this.f10419;
                        int i21 = i20 != 0 && this.f10417 != 0 && this.f10420 <= i20 * 3 && i20 * 2 > this.f10418 * 3 ? this.f10417 : iM5796;
                        this.f10418 = this.f10419;
                        this.f10417 = iM5796;
                        if (d > 1.0d) {
                            short[] sArr2 = this.f10408;
                            if (f3 >= 2.0f) {
                                i2 = (int) (i21 / (f3 - f5));
                            } else {
                                this.f10416 = (int) (((2.0f - f3) * i21) / (f3 - f5));
                                i2 = i21;
                            }
                            short[] sArrM5800 = m5800(this.f10410, this.f10411, i2);
                            this.f10410 = sArrM5800;
                            int i22 = i2;
                            m5795(i2, this.f10400, sArrM5800, this.f10411, sArr2, i10, sArr2, i10 + i21);
                            this.f10411 += i22;
                            i10 = i21 + i22 + i10;
                        } else {
                            int i23 = i21;
                            short[] sArr3 = this.f10408;
                            if (f3 < 0.5f) {
                                i = (int) ((i23 * f3) / (f5 - f3));
                            } else {
                                this.f10416 = (int) ((((2.0f * f3) - f5) * i23) / (f5 - f3));
                                i = i23;
                            }
                            int i24 = i23 + i;
                            short[] sArrM58002 = m5800(this.f10410, this.f10411, i24);
                            this.f10410 = sArrM58002;
                            int i25 = this.f10400;
                            System.arraycopy(sArr3, i10 * i25, sArrM58002, this.f10411 * i25, i25 * i23);
                            m5795(i, this.f10400, this.f10410, this.f10411 + i23, sArr3, i10 + i23, sArr3, i10);
                            this.f10411 += i24;
                            i10 += i;
                        }
                    }
                    if (this.f10406 + i10 > i9) {
                        break;
                    }
                    f5 = 1.0f;
                    i8 = 1;
                }
                int i26 = this.f10409 - i10;
                short[] sArr4 = this.f10408;
                int i27 = this.f10400;
                System.arraycopy(sArr4, i10 * i27, sArr4, 0, i27 * i26);
                this.f10409 = i26;
            }
            f5 = 1.0f;
        } else {
            m5798(this.f10408, 0, this.f10409);
            this.f10409 = 0;
        }
        if (f4 == f5 || this.f10411 == i7) {
            return;
        }
        int i28 = this.f10399;
        int i29 = (int) (i28 / f4);
        while (true) {
            if (i29 <= 16384 && i28 <= 16384) {
                break;
            }
            i29 /= 2;
            i28 /= 2;
        }
        int i30 = this.f10411 - i7;
        short[] sArrM58003 = m5800(this.f10412, this.f10413, i30);
        this.f10412 = sArrM58003;
        short[] sArr5 = this.f10410;
        int i31 = this.f10400;
        System.arraycopy(sArr5, i7 * i31, sArrM58003, this.f10413 * i31, i31 * i30);
        this.f10411 = i7;
        this.f10413 += i30;
        int i32 = 0;
        while (true) {
            i3 = this.f10413;
            i4 = i3 - 1;
            if (i32 >= i4) {
                break;
            }
            while (true) {
                i5 = this.f10414 + 1;
                int i33 = i5 * i29;
                i6 = this.f10415;
                if (i33 <= i6 * i28) {
                    break;
                }
                this.f10410 = m5800(this.f10410, this.f10411, 1);
                int i34 = 0;
                while (true) {
                    int i35 = this.f10400;
                    if (i34 < i35) {
                        short[] sArr6 = this.f10410;
                        int i36 = (this.f10411 * i35) + i34;
                        short[] sArr7 = this.f10412;
                        int i37 = (i32 * i35) + i34;
                        short s = sArr7[i37];
                        short s2 = sArr7[i37 + i35];
                        int i38 = this.f10415 * i28;
                        int i39 = this.f10414;
                        int i40 = i39 * i29;
                        int i41 = (i39 + 1) * i29;
                        int i42 = i41 - i38;
                        int i43 = i41 - i40;
                        sArr6[i36] = (short) ((((i43 - i42) * s2) + (s * i42)) / i43);
                        i34++;
                    }
                }
                this.f10415++;
                this.f10411++;
            }
            this.f10414 = i5;
            if (i5 == i28) {
                this.f10414 = 0;
                C0567.m1932(i6 == i29);
                this.f10415 = 0;
            }
            i32++;
        }
        if (i4 == 0) {
            return;
        }
        short[] sArr8 = this.f10412;
        int i44 = this.f10400;
        System.arraycopy(sArr8, i4 * i44, sArr8, 0, (i3 - i4) * i44);
        this.f10413 -= i4;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m5798(short[] sArr, int i, int i2) {
        short[] sArrM5800 = m5800(this.f10410, this.f10411, i2);
        this.f10410 = sArrM5800;
        int i3 = this.f10400;
        System.arraycopy(sArr, i * i3, sArrM5800, this.f10411 * i3, i3 * i2);
        this.f10411 += i2;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m5799(short[] sArr, int i, int i2) {
        int i3 = this.f10406 / i2;
        int i4 = this.f10400;
        int i5 = i2 * i4;
        int i6 = i * i4;
        for (int i7 = 0; i7 < i3; i7++) {
            int i8 = 0;
            for (int i9 = 0; i9 < i5; i9++) {
                i8 += sArr[(i7 * i5) + i6 + i9];
            }
            this.f10407[i7] = (short) (i8 / i5);
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final short[] m5800(short[] sArr, int i, int i2) {
        int length = sArr.length;
        int i3 = this.f10400;
        int i4 = length / i3;
        return i + i2 <= i4 ? sArr : Arrays.copyOf(sArr, (((i4 * 3) / 2) + i2) * i3);
    }
}
