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

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.MimeTypes;
import java.nio.ByteOrder;
import java.util.Collections;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final long f18648j;

    @Nullable
    public final x2 zzk;

    @Nullable
    private final ta zzl;

    @VisibleForTesting
    public y2(int i10, int i11, int i12, int i13, int i14, int i15, int i16, long j10, @Nullable x2 x2Var, @Nullable ta taVar) {
        this.f18639a = i10;
        this.f18640b = i11;
        this.f18641c = i12;
        this.f18642d = i13;
        this.f18643e = i14;
        this.f18644f = b(i14);
        this.f18645g = i15;
        this.f18646h = i16;
        this.f18647i = c(i16);
        this.f18648j = j10;
        this.zzk = x2Var;
        this.zzl = taVar;
    }

    public static int b(int i10) {
        switch (i10) {
            case 8000:
                return 4;
            case 16000:
                return 5;
            case 22050:
                return 6;
            case 24000:
                return 7;
            case 32000:
                return 8;
            case 44100:
                return 9;
            case 48000:
                return 10;
            case 88200:
                return 1;
            case 96000:
                return 11;
            case 176400:
                return 2;
            case 192000:
                return 3;
            default:
                return -1;
        }
    }

    public static int c(int i10) {
        if (i10 == 8) {
            return 1;
        }
        if (i10 == 12) {
            return 2;
        }
        if (i10 == 16) {
            return 4;
        }
        if (i10 == 20) {
            return 5;
        }
        if (i10 != 24) {
            return i10 != 32 ? -1 : 7;
        }
        return 6;
    }

    public final long a() {
        long j10 = this.f18648j;
        if (j10 == 0) {
            return -9223372036854775807L;
        }
        return (j10 * 1000000) / ((long) this.f18643e);
    }

    public final zn2 zzc(byte[] bArr, @Nullable ta taVar) {
        bArr[4] = -128;
        ta taVarZzd = zzd(taVar);
        sm2 sm2Var = new sm2();
        sm2Var.zzm(MimeTypes.AUDIO_FLAC);
        int i10 = this.f18642d;
        if (i10 <= 0) {
            i10 = -1;
        }
        sm2Var.f16483f = i10;
        sm2Var.f16496s = this.f18645g;
        sm2Var.f16497t = this.f18643e;
        sm2Var.f16498u = bb1.v(this.f18646h, ByteOrder.LITTLE_ENDIAN);
        sm2Var.zzp(Collections.singletonList(bArr));
        sm2Var.zzk(taVarZzd);
        return new zn2(sm2Var);
    }

    @Nullable
    public final ta zzd(@Nullable ta taVar) {
        ta taVar2 = this.zzl;
        return taVar2 == null ? taVar : taVar2.zzf(taVar);
    }

    public final y2 zze(@Nullable x2 x2Var) {
        return new y2(this.f18639a, this.f18640b, this.f18641c, this.f18642d, this.f18643e, this.f18645g, this.f18646h, this.f18648j, x2Var, this.zzl);
    }

    public y2(byte[] bArr, int i10) {
        androidx.media3.extractor.b1 b1Var = new androidx.media3.extractor.b1(bArr, bArr.length);
        b1Var.l(i10 * 8);
        this.f18639a = b1Var.p(16);
        this.f18640b = b1Var.p(16);
        this.f18641c = b1Var.p(24);
        this.f18642d = b1Var.p(24);
        int iP = b1Var.p(20);
        this.f18643e = iP;
        this.f18644f = b(iP);
        this.f18645g = b1Var.p(3) + 1;
        int iP2 = b1Var.p(5) + 1;
        this.f18646h = iP2;
        this.f18647i = c(iP2);
        this.f18648j = b1Var.q(36);
        this.zzk = null;
        this.zzl = null;
    }
}
