package defpackage;

import androidx.media3.common.audio.AudioProcessor$UnhandledAudioFormatException;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/* JADX INFO: renamed from: ᵛᵯ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2810 implements InterfaceC2497 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public int f10795;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public C2917 f10796;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public long f10797;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public float f10798;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public long f10799;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public C2917 f10800;

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public boolean f10801;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public ByteBuffer f10802;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public C4739 f10803;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public C2917 f10804;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public ByteBuffer f10805;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public float f10806;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public boolean f10807;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public C2917 f10808;

    @Override // defpackage.InterfaceC2497
    public final void reset() {
        this.f10798 = 1.0f;
        this.f10806 = 1.0f;
        C2917 c2917 = C2917.f11219;
        this.f10800 = c2917;
        this.f10808 = c2917;
        this.f10804 = c2917;
        this.f10796 = c2917;
        ByteBuffer byteBuffer = InterfaceC2497.f9685;
        this.f10805 = byteBuffer;
        this.f10802 = byteBuffer;
        this.f10795 = -1;
        this.f10807 = false;
        this.f10803 = null;
        this.f10799 = 0L;
        this.f10797 = 0L;
        this.f10801 = false;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ʽˈˋ */
    public final boolean mo4908() {
        if (this.f10801) {
            C4739 c4739 = this.f10803;
            if (c4739 != null) {
                ᵻᵪ.ˌᴵ(c4739.f18028 >= 0);
                if (c4739.f18030.mo1288() * c4739.f18028 * c4739.f18015 == 0) {
                }
            }
            return true;
        }
        return false;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ˊᵫᵗ */
    public final void mo4909() {
        C4739 c4739 = this.f10803;
        if (c4739 != null) {
            int i = c4739.f18025;
            float f = c4739.f18018;
            float f2 = c4739.f18029;
            double d = f / f2;
            double d2 = c4739.f18021 * f2;
            int i2 = c4739.f18022;
            int i3 = c4739.f18028 + ((int) ((((((((double) (i - i2)) / d) + ((double) i2)) + c4739.f18024) + ((double) c4739.f18023)) / d2) + 0.5d));
            c4739.f18024 = 0.0d;
            InterfaceC2633 interfaceC2633 = c4739.f18030;
            int i4 = c4739.f18016 * 2;
            interfaceC2633.mo1286(i4 + i);
            interfaceC2633.mo1284(i * c4739.f18015, i4);
            c4739.f18025 = i4 + c4739.f18025;
            c4739.m9901();
            if (c4739.f18028 > i3) {
                c4739.f18028 = Math.max(i3, 0);
            }
            c4739.f18025 = 0;
            c4739.f18022 = 0;
            c4739.f18023 = 0;
        }
        this.f10801 = true;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final boolean mo3847() {
        if (this.f10808.f11222 != -1) {
            return Math.abs(this.f10798 - 1.0f) >= 1.0E-4f || Math.abs(this.f10806 - 1.0f) >= 1.0E-4f || this.f10808.f11222 != this.f10800.f11222;
        }
        return false;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ᵨᵣ */
    public final void mo4911(C2995 c2995) {
        if (mo3847()) {
            C2917 c2917 = this.f10800;
            this.f10804 = c2917;
            C2917 c29172 = this.f10808;
            this.f10796 = c29172;
            if (this.f10807) {
                this.f10803 = new C4739(c2917.f11222, c2917.f11220, this.f10798, this.f10806, c29172.f11222, c2917.f11221 == 4);
            } else {
                C4739 c4739 = this.f10803;
                if (c4739 != null) {
                    c4739.f18025 = 0;
                    c4739.f18028 = 0;
                    c4739.f18023 = 0;
                    c4739.f18019 = 0;
                    c4739.f18017 = 0;
                    c4739.f18022 = 0;
                    c4739.f18020 = 0;
                    c4739.f18024 = 0.0d;
                    c4739.f18030.flush();
                }
            }
        }
        this.f10802 = InterfaceC2497.f9685;
        this.f10799 = 0L;
        this.f10797 = 0L;
        this.f10801 = false;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ᵵᵽ */
    public final C2917 mo4912(C2917 c2917) throws AudioProcessor$UnhandledAudioFormatException {
        int i = c2917.f11221;
        if (i != 2 && i != 4) {
            throw new AudioProcessor$UnhandledAudioFormatException(c2917);
        }
        int i2 = this.f10795;
        if (i2 == -1) {
            i2 = c2917.f11222;
        }
        this.f10800 = c2917;
        C2917 c29172 = new C2917(i2, c2917.f11220, i);
        this.f10808 = c29172;
        this.f10807 = true;
        return c29172;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    public final ByteBuffer mo4913() {
        C4739 c4739 = this.f10803;
        if (c4739 != null) {
            InterfaceC2633 interfaceC2633 = c4739.f18030;
            int i = c4739.f18015;
            ᵻᵪ.ˌᴵ(c4739.f18028 >= 0);
            int iMo1288 = interfaceC2633.mo1288() * c4739.f18028 * i;
            if (iMo1288 > 0) {
                if (this.f10805.capacity() < iMo1288) {
                    this.f10805 = ByteBuffer.allocateDirect(iMo1288).order(ByteOrder.nativeOrder());
                } else {
                    this.f10805.clear();
                }
                ByteBuffer byteBuffer = this.f10805;
                ᵻᵪ.ˌᴵ(c4739.f18028 >= 0);
                int iMin = Math.min(byteBuffer.remaining() / (interfaceC2633.mo1288() * i), c4739.f18028);
                interfaceC2633.mo1279(iMin, byteBuffer);
                c4739.f18028 -= iMin;
                System.arraycopy(interfaceC2633.mo1282(), iMin * i, interfaceC2633.mo1282(), 0, c4739.f18028 * i);
                this.f10805.flip();
                this.f10797 += (long) iMo1288;
                this.f10802 = this.f10805;
            }
        }
        ByteBuffer byteBuffer2 = this.f10802;
        this.f10802 = InterfaceC2497.f9685;
        return byteBuffer2;
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final long mo4914(long j) {
        if (this.f10797 < 1024) {
            return (long) (j / ((double) this.f10798));
        }
        long j2 = this.f10799;
        C4739 c4739 = this.f10803;
        c4739.getClass();
        long jMo1288 = j2 - ((long) (c4739.f18030.mo1288() * (c4739.f18025 * c4739.f18015)));
        int i = this.f10796.f11222;
        int i2 = this.f10804.f11222;
        long j3 = this.f10797;
        return i == i2 ? AbstractC0956.m3218(j, j3, jMo1288, RoundingMode.DOWN) : AbstractC0956.m3218(j, j3 * ((long) i2), jMo1288 * ((long) i), RoundingMode.DOWN);
    }

    @Override // defpackage.InterfaceC2497
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final void mo3789(ByteBuffer byteBuffer) {
        if (byteBuffer.hasRemaining()) {
            C4739 c4739 = this.f10803;
            c4739.getClass();
            this.f10799 += (long) byteBuffer.remaining();
            int iRemaining = byteBuffer.remaining();
            int i = c4739.f18015;
            InterfaceC2633 interfaceC2633 = c4739.f18030;
            int iMo1288 = iRemaining / (interfaceC2633.mo1288() * i);
            interfaceC2633.mo1286(iMo1288);
            interfaceC2633.mo1292(iRemaining, byteBuffer);
            c4739.f18025 += iMo1288;
            c4739.m9901();
        }
    }
}
