package defpackage;

import android.media.MediaCodec;
import android.os.Build;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;

/* renamed from: ᵯʓː, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4247 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public C3063 f15906;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public long f15907;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public C3063 f15908;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C3493 f15909;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ᵧˉʙ f15910;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final int f15911;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public C3063 f15912;

    public C4247(ᵧˉʙ r4) {
        int i;
        this.f15910 = r4;
        synchronized (r4) {
            i = ((C4002) r4.ᵾᵬ).f15051.f3970;
        }
        this.f15911 = i;
        this.f15909 = new C3493(32);
        C3063 c3063 = new C3063(0L, i);
        this.f15912 = c3063;
        this.f15906 = c3063;
        this.f15908 = c3063;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static C3063 m9188(C3063 c3063, long j, byte[] bArr, int i) {
        while (j >= c3063.f11723) {
            c3063 = (C3063) c3063.f11725;
        }
        int i2 = i;
        while (i2 > 0) {
            int iMin = Math.min(i2, (int) (c3063.f11723 - j));
            C1197 c1197 = (C1197) c3063.f11726;
            System.arraycopy(c1197.f5102, ((int) (j - c3063.f11724)) + c1197.f5103, bArr, i - i2, iMin);
            i2 -= iMin;
            j += iMin;
            if (j == c3063.f11723) {
                c3063 = (C3063) c3063.f11725;
            }
        }
        return c3063;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static C3063 m9189(C3063 c3063, C2441 c2441, C4395 c4395, C3493 c3493) {
        if (c2441.m9873(1073741824)) {
            long j = c4395.f16458;
            int iM7972 = 1;
            c3493.m7939(1);
            C3063 c3063M9188 = m9188(c3063, j, c3493.f13082, 1);
            long j2 = j + 1;
            byte b = c3493.f13082[0];
            boolean z = (b & 128) != 0;
            int i = b & Byte.MAX_VALUE;
            C3937 c3937 = c2441.f9518;
            byte[] bArr = c3937.f14870;
            if (bArr == null) {
                c3937.f14870 = new byte[16];
            } else {
                Arrays.fill(bArr, (byte) 0);
            }
            c3063 = m9188(c3063M9188, j2, c3937.f14870, i);
            long j3 = j2 + i;
            if (z) {
                c3493.m7939(2);
                c3063 = m9188(c3063, j3, c3493.f13082, 2);
                j3 += 2;
                iM7972 = c3493.m7972();
            }
            int[] iArr = c3937.f14874;
            if (iArr == null || iArr.length < iM7972) {
                iArr = new int[iM7972];
            }
            int[] iArr2 = c3937.f14865;
            if (iArr2 == null || iArr2.length < iM7972) {
                iArr2 = new int[iM7972];
            }
            if (z) {
                int i2 = iM7972 * 6;
                c3493.m7939(i2);
                c3063 = m9188(c3063, j3, c3493.f13082, i2);
                j3 += i2;
                c3493.m7955(0);
                for (int i3 = 0; i3 < iM7972; i3++) {
                    iArr[i3] = c3493.m7972();
                    iArr2[i3] = c3493.m7943();
                }
            } else {
                iArr[0] = 0;
                iArr2[0] = c4395.f16457 - ((int) (j3 - c4395.f16458));
            }
            C5346 c5346 = (C5346) c4395.f16456;
            String str = AbstractC3558.f13329;
            byte[] bArr2 = c5346.f20030;
            byte[] bArr3 = c3937.f14870;
            int i4 = c5346.f20029;
            int i5 = c5346.f20028;
            int i6 = c5346.f20031;
            c3937.f14867 = iM7972;
            c3937.f14874 = iArr;
            c3937.f14865 = iArr2;
            c3937.f14871 = bArr2;
            c3937.f14870 = bArr3;
            c3937.f14868 = i4;
            c3937.f14866 = i5;
            c3937.f14873 = i6;
            MediaCodec.CryptoInfo cryptoInfo = c3937.f14869;
            cryptoInfo.numSubSamples = iM7972;
            cryptoInfo.numBytesOfClearData = iArr;
            cryptoInfo.numBytesOfEncryptedData = iArr2;
            cryptoInfo.key = bArr2;
            cryptoInfo.iv = bArr3;
            cryptoInfo.mode = i4;
            if (Build.VERSION.SDK_INT >= 24) {
                C4075 c4075 = c3937.f14872;
                c4075.getClass();
                C4075.m8942(c4075, i5, i6);
            }
            long j4 = c4395.f16458;
            int i7 = (int) (j3 - j4);
            c4395.f16458 = j4 + i7;
            c4395.f16457 -= i7;
        }
        if (!c2441.m9873(268435456)) {
            c2441.m6222(c4395.f16457);
            return m9190(c3063, c4395.f16458, c2441.f9517, c4395.f16457);
        }
        c3493.m7939(4);
        C3063 c3063M91882 = m9188(c3063, c4395.f16458, c3493.f13082, 4);
        int iM7943 = c3493.m7943();
        c4395.f16458 += 4;
        c4395.f16457 -= 4;
        c2441.m6222(iM7943);
        C3063 c3063M9190 = m9190(c3063M91882, c4395.f16458, c2441.f9517, iM7943);
        c4395.f16458 += iM7943;
        int i8 = c4395.f16457 - iM7943;
        c4395.f16457 = i8;
        ByteBuffer byteBuffer = c2441.f9515;
        if (byteBuffer == null || byteBuffer.capacity() < i8) {
            c2441.f9515 = ByteBuffer.allocate(i8);
        } else {
            c2441.f9515.clear();
        }
        return m9190(c3063M9190, c4395.f16458, c2441.f9515, c4395.f16457);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static C3063 m9190(C3063 c3063, long j, ByteBuffer byteBuffer, int i) {
        while (j >= c3063.f11723) {
            c3063 = (C3063) c3063.f11725;
        }
        while (i > 0) {
            int iMin = Math.min(i, (int) (c3063.f11723 - j));
            C1197 c1197 = (C1197) c3063.f11726;
            byteBuffer.put(c1197.f5102, ((int) (j - c3063.f11724)) + c1197.f5103, iMin);
            i -= iMin;
            j += iMin;
            if (j == c3063.f11723) {
                c3063 = (C3063) c3063.f11725;
            }
        }
        return c3063;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int m9191(int i) {
        C1197 c1197M2999;
        C3063 c3063 = this.f15908;
        if (((C1197) c3063.f11726) == null) {
            ᵧˉʙ r1 = this.f15910;
            synchronized (r1) {
                c1197M2999 = ((C4002) r1.ᵾᵬ).f15051.m2999();
                ((HashMap) r1.ᵢˇᵭ).put(c1197M2999, (C1545) r1.ᵿʗᵝʽ);
                C0067 c0067 = (C0067) ((C4002) r1.ᵾᵬ).f15047.get((C1545) r1.ᵿʗᵝʽ);
                if (c0067 != null) {
                    c0067.m1140();
                }
            }
            C3063 c30632 = new C3063(this.f15908.f11723, this.f15911);
            c3063.f11726 = c1197M2999;
            c3063.f11725 = c30632;
        }
        return Math.min(i, (int) (this.f15908.f11723 - this.f15907));
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m9192(C3063 c3063) {
        if (((C1197) c3063.f11726) == null) {
            return;
        }
        ᵧˉʙ r3 = this.f15910;
        synchronized (r3) {
            ((C4002) r3.ᵾᵬ).f15051.m2998(c3063);
            C3063 c30632 = c3063;
            while (c30632 != null) {
                C1197 c1197 = (C1197) c30632.f11726;
                c1197.getClass();
                r3.ﾞⁱ(c1197);
                c30632 = (C3063) c30632.f11725;
                if (c30632 == null || ((C1197) c30632.f11726) == null) {
                    c30632 = null;
                }
            }
        }
        c3063.f11726 = null;
        c3063.f11725 = null;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m9193(long j) {
        C3063 c3063;
        if (j == -1) {
            return;
        }
        while (true) {
            c3063 = this.f15912;
            if (j < c3063.f11723) {
                break;
            }
            ᵧˉʙ r1 = this.f15910;
            C1197 c1197 = (C1197) c3063.f11726;
            synchronized (r1) {
                ((C4002) r1.ᵾᵬ).f15051.m3000(c1197);
                r1.ﾞⁱ(c1197);
            }
            C3063 c30632 = this.f15912;
            c30632.f11726 = null;
            C3063 c30633 = (C3063) c30632.f11725;
            c30632.f11725 = null;
            this.f15912 = c30633;
        }
        if (this.f15906.f11724 < c3063.f11724) {
            this.f15906 = c3063;
        }
    }
}
