package k2;

import androidx.annotation.Nullable;
import androidx.media3.common.util.ParsableByteArray;
import androidx.media3.common.util.Util;
import androidx.media3.extractor.q0;

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

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

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

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

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

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

    @Nullable
    public final long[] tableOfContents;

    private h(q0 q0Var, long j10, long j11, @Nullable long[] jArr, int i10, int i11) {
        q0 q0Var2 = new q0();
        q0Var2.f3450a = q0Var.f3450a;
        q0Var2.mimeType = q0Var.mimeType;
        q0Var2.f3451b = q0Var.f3451b;
        q0Var2.f3452c = q0Var.f3452c;
        q0Var2.f3453d = q0Var.f3453d;
        q0Var2.f3454e = q0Var.f3454e;
        q0Var2.f3455f = q0Var.f3455f;
        this.f29051a = q0Var2;
        this.f29052b = j10;
        this.f29053c = j11;
        this.tableOfContents = jArr;
        this.f29054d = i10;
        this.f29055e = i11;
    }

    public static h b(q0 q0Var, ParsableByteArray parsableByteArray) {
        long[] jArr;
        int i10;
        int i11;
        int i12 = parsableByteArray.readInt();
        int unsignedIntToInt = (i12 & 1) != 0 ? parsableByteArray.readUnsignedIntToInt() : -1;
        long unsignedInt = (i12 & 2) != 0 ? parsableByteArray.readUnsignedInt() : -1L;
        if ((i12 & 4) == 4) {
            long[] jArr2 = new long[100];
            for (int i13 = 0; i13 < 100; i13++) {
                jArr2[i13] = parsableByteArray.readUnsignedByte();
            }
            jArr = jArr2;
        } else {
            jArr = null;
        }
        if ((i12 & 8) != 0) {
            parsableByteArray.skipBytes(4);
        }
        if (parsableByteArray.bytesLeft() >= 24) {
            parsableByteArray.skipBytes(21);
            int unsignedInt24 = parsableByteArray.readUnsignedInt24();
            i11 = unsignedInt24 & 4095;
            i10 = (16773120 & unsignedInt24) >> 12;
        } else {
            i10 = -1;
            i11 = -1;
        }
        return new h(q0Var, unsignedIntToInt, unsignedInt, jArr, i10, i11);
    }

    public final long a() {
        long j10 = this.f29052b;
        if (j10 == -1 || j10 == 0) {
            return -9223372036854775807L;
        }
        q0 q0Var = this.f29051a;
        return Util.sampleCountToDurationUs((j10 * ((long) q0Var.f3455f)) - 1, q0Var.f3452c);
    }
}
