package T0;

import O1.C0225a;
import java.util.Collections;
import u0.C1578n;
import u0.C1579o;

/* JADX INFO: loaded from: classes.dex */
public final class r {

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final C0225a f6453k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final u0.D f6454l;

    public r(int i, byte[] bArr) {
        H h8 = new H(bArr.length, bArr);
        h8.q(i * 8);
        this.f6444a = h8.i(16);
        this.f6445b = h8.i(16);
        this.f6446c = h8.i(24);
        this.f6447d = h8.i(24);
        int i5 = h8.i(20);
        this.f6448e = i5;
        this.f6449f = d(i5);
        this.f6450g = h8.i(3) + 1;
        int i8 = h8.i(5) + 1;
        this.f6451h = i8;
        this.i = a(i8);
        this.f6452j = h8.k(36);
        this.f6453k = null;
        this.f6454l = null;
    }

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

    public static int d(int i) {
        switch (i) {
            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 final long b() {
        long j8 = this.f6452j;
        if (j8 == 0) {
            return -9223372036854775807L;
        }
        return (j8 * 1000000) / ((long) this.f6448e);
    }

    public final C1579o c(byte[] bArr, u0.D d8) {
        bArr[4] = -128;
        int i = this.f6447d;
        if (i <= 0) {
            i = -1;
        }
        u0.D d9 = this.f6454l;
        if (d9 != null) {
            d8 = d9.b(d8);
        }
        C1578n c1578n = new C1578n();
        c1578n.f17320m = u0.E.m("audio/flac");
        c1578n.f17321n = i;
        c1578n.f17301C = this.f6450g;
        c1578n.D = this.f6448e;
        c1578n.f17302E = x0.v.y(this.f6451h);
        c1578n.f17323p = Collections.singletonList(bArr);
        c1578n.f17318k = d8;
        return new C1579o(c1578n);
    }

    public r(int i, int i5, int i8, int i9, int i10, int i11, int i12, long j8, C0225a c0225a, u0.D d8) {
        this.f6444a = i;
        this.f6445b = i5;
        this.f6446c = i8;
        this.f6447d = i9;
        this.f6448e = i10;
        this.f6449f = d(i10);
        this.f6450g = i11;
        this.f6451h = i12;
        this.i = a(i12);
        this.f6452j = j8;
        this.f6453k = c0225a;
        this.f6454l = d8;
    }
}
