package com.google.android.gms.internal.ads;

import tv.danmaku.ijk.media.player.IjkEventListener;

/* JADX INFO: loaded from: classes2.dex */
public final class pa0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f15329a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f15330b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final float f15331c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final float f15332d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final float f15333e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int f15334f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final int f15335g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final int f15336h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final s90 f15337i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f15338j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f15339k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f15340l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f15341m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f15342n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f15343o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f15344p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public double f15345q;

    public pa0(int i10, int i11, float f10, float f11, int i12, boolean z10) {
        this.f15329a = i10;
        this.f15330b = i11;
        this.f15331c = f10;
        this.f15332d = f11;
        this.f15333e = i10 / i12;
        this.f15334f = i10 / IjkEventListener.VIDEO_SIZE_CHANGED;
        int i13 = i10 / 65;
        this.f15335g = i13;
        this.f15336h = i13 + i13;
        this.f15337i = z10 ? new g90(this) : new ca0(this);
    }

    public final void a(int i10, int i11) {
        s90 s90Var = this.f15337i;
        s90Var.a(i11);
        Object objZzr = s90Var.zzr();
        Object objZzq = s90Var.zzq();
        int i12 = this.f15339k;
        int i13 = this.f15330b;
        System.arraycopy(objZzr, i10 * i13, objZzq, i12 * i13, i11 * i13);
        this.f15339k += i11;
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x00a6  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00aa  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00bb  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x010f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void b() {
        int i10;
        int i11;
        int i12;
        int i13;
        int i14;
        s90 s90Var;
        double d10;
        int i15;
        s90 s90Var2;
        int i16;
        float f10;
        int i17;
        int i18;
        long j10;
        long j11;
        float f11 = this.f15331c;
        float f12 = this.f15332d;
        double d11 = f11 / f12;
        int i19 = this.f15339k;
        int i20 = this.f15329a;
        int i21 = this.f15330b;
        s90 s90Var3 = this.f15337i;
        int i22 = 1;
        if (d11 > 1.0000100135803223d || d11 < 0.9999899864196777d) {
            int i23 = this.f15338j;
            int i24 = this.f15336h;
            if (i23 >= i24) {
                int i25 = 0;
                while (true) {
                    int i26 = this.f15343o;
                    if (i26 > 0) {
                        int iMin = Math.min(i24, i26);
                        a(i25, iMin);
                        this.f15343o -= iMin;
                        i25 += iMin;
                        d10 = d11;
                        i14 = i20;
                        i11 = i24;
                        s90Var = s90Var3;
                    } else {
                        int i27 = i20 > 4000 ? i20 / 4000 : i22;
                        int i28 = this.f15335g;
                        int i29 = this.f15334f;
                        if (i21 != i22) {
                            i10 = i21;
                        } else if (i27 == i22) {
                            i12 = s90Var3.b(i25, i29, i28);
                            i11 = i24;
                            i13 = i22;
                            int i30 = !s90Var3.zzc() ? this.f15344p : i12;
                            int i31 = i25 + i30;
                            s90Var3.zzi();
                            this.f15344p = i12;
                            double d12 = i30;
                            if (d11 <= 1.0d) {
                                double d13 = d11 - 1.0d;
                                if (d11 >= 2.0d) {
                                    s90Var2 = s90Var3;
                                    double d14 = (d12 / d13) + this.f15345q;
                                    int iRound = (int) Math.round(d14);
                                    this.f15345q = d14 - ((double) iRound);
                                    i16 = iRound;
                                } else {
                                    s90Var2 = s90Var3;
                                    double d15 = ((d12 * (2.0d - d11)) / d13) + this.f15345q;
                                    int iRound2 = (int) Math.round(d15);
                                    this.f15343o = iRound2;
                                    this.f15345q = d15 - ((double) iRound2);
                                    i16 = i30;
                                }
                                s90 s90Var4 = s90Var2;
                                s90Var4.a(i16);
                                int i32 = i25;
                                i14 = i20;
                                s90Var = s90Var4;
                                s90Var4.e(i16, i13, this.f15339k, i32, i31);
                                this.f15339k += i16;
                                d10 = d11;
                                i25 = i30 + i16 + i32;
                            } else {
                                i14 = i20;
                                int i33 = i25;
                                s90Var = s90Var3;
                                double d16 = 1.0d - d11;
                                if (d11 < 0.5d) {
                                    double d17 = ((d12 * d11) / d16) + this.f15345q;
                                    int iRound3 = (int) Math.round(d17);
                                    this.f15345q = d17 - ((double) iRound3);
                                    d10 = d11;
                                    i15 = iRound3;
                                } else {
                                    d10 = d11;
                                    double d18 = ((d12 * ((d11 + d11) - 1.0d)) / d16) + this.f15345q;
                                    int iRound4 = (int) Math.round(d18);
                                    this.f15343o = iRound4;
                                    this.f15345q = d18 - ((double) iRound4);
                                    i15 = i30;
                                }
                                int i34 = i30 + i15;
                                s90Var.a(i34);
                                System.arraycopy(s90Var.zzr(), i33 * i13, s90Var.zzq(), this.f15339k * i13, i30 * i13);
                                s90Var.e(i15, i13, this.f15339k + i30, i31, i33);
                                this.f15339k += i34;
                                i25 = i33 + i15;
                            }
                        } else {
                            i10 = i22;
                        }
                        s90Var3.f(i25, i27);
                        i11 = i24;
                        int i35 = s90Var3.i(i29 / i27, i28 / i27);
                        if (i27 != 1) {
                            int i36 = i35 * i27;
                            int i37 = i27 * 4;
                            int i38 = i36 - i37;
                            if (i38 >= i29) {
                                i29 = i38;
                            }
                            int i39 = i36 + i37;
                            if (i39 <= i28) {
                                i28 = i39;
                            }
                            if (i10 == 1) {
                                i12 = s90Var3.b(i25, i29, i28);
                            } else {
                                s90Var3.f(i25, 1);
                                i12 = s90Var3.i(i29, i28);
                            }
                        } else {
                            i12 = i35;
                        }
                        i13 = i10;
                        if (!s90Var3.zzc()) {
                        }
                        int i312 = i25 + i30;
                        s90Var3.zzi();
                        this.f15344p = i12;
                        double d122 = i30;
                        if (d11 <= 1.0d) {
                        }
                    }
                    if (i25 + i11 > i23) {
                        break;
                    }
                    s90Var3 = s90Var;
                    i24 = i11;
                    i20 = i14;
                    d11 = d10;
                    i22 = 1;
                }
                int i40 = this.f15338j - i25;
                System.arraycopy(s90Var.zzr(), i25 * i21, s90Var.zzr(), 0, i40 * i21);
                this.f15338j = i40;
            }
            f10 = this.f15333e * f12;
            if (f10 != 1.0f || this.f15339k == i19) {
            }
            int i41 = i14;
            float f13 = i41 / f10;
            long j12 = i41;
            long j13 = (long) f13;
            while (j13 != 0 && j12 != 0 && j13 % 2 == 0 && j12 % 2 == 0) {
                j13 /= 2;
                j12 /= 2;
            }
            int i42 = this.f15339k - i19;
            s90Var.d(i42);
            System.arraycopy(s90Var.zzq(), i19 * i21, s90Var.zzp(), this.f15340l * i21, i42 * i21);
            this.f15339k = i19;
            this.f15340l += i42;
            int i43 = 0;
            while (true) {
                i17 = this.f15340l - 1;
                if (i43 >= i17) {
                    break;
                }
                while (true) {
                    i18 = this.f15341m + 1;
                    j10 = i18;
                    long j14 = j10 * j13;
                    j11 = this.f15342n;
                    if (j14 <= j11 * j12) {
                        break;
                    }
                    s90Var.a(1);
                    s90Var.c(i43, j12, j13);
                    this.f15342n++;
                    this.f15339k++;
                }
                this.f15341m = i18;
                if (j10 == j12) {
                    this.f15341m = 0;
                    ih1.b1(j11 == j13);
                    this.f15342n = 0;
                }
                i43++;
            }
            if (i17 != 0) {
                System.arraycopy(s90Var.zzp(), i17 * i21, s90Var.zzp(), 0, (this.f15340l - i17) * i21);
                this.f15340l -= i17;
                return;
            }
            return;
        }
        a(0, this.f15338j);
        this.f15338j = 0;
        i14 = i20;
        s90Var = s90Var3;
        f10 = this.f15333e * f12;
        if (f10 != 1.0f) {
        }
    }
}
