zoomvtools 1.1.0

Video motion vector analysis utilities in pure Rust
Documentation
/// Returns `true` if the current machine supports the AVX2 instruction set.
#[cfg(all(target_arch = "x86_64", feature = "avx2", target_feature = "avx2"))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[inline]
pub fn has_avx2() -> bool {
    true
}

/// Returns `true` if the current machine supports the AVX2 instruction set.
#[cfg(all(target_arch = "x86_64", feature = "avx2", not(target_feature = "avx2")))]
#[must_use]
#[inline]
pub fn has_avx2() -> bool {
    is_x86_feature_detected!("avx2")
}

/// Returns `true` if the current machine supports the AVX2 instruction set.
#[cfg(not(all(target_arch = "x86_64", feature = "avx2")))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx2() -> bool {
    false
}

// Feature set supported by Skylake, Cannon Lake, Cascade Lake, Cooper Lake, and later
#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    all(
        target_feature = "avx512f",
        target_feature = "avx512cd",
        target_feature = "avx512vl",
        target_feature = "avx512dq",
        target_feature = "avx512bw"
    )
))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[inline]
pub fn has_avx512_skylake() -> bool {
    true
}

#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    not(all(
        target_feature = "avx512f",
        target_feature = "avx512cd",
        target_feature = "avx512vl",
        target_feature = "avx512dq",
        target_feature = "avx512bw"
    ))
))]
#[must_use]
#[inline]
pub fn has_avx512_skylake() -> bool {
    is_x86_feature_detected!("avx512f")
        && is_x86_feature_detected!("avx512cd")
        && is_x86_feature_detected!("avx512vl")
        && is_x86_feature_detected!("avx512dq")
        && is_x86_feature_detected!("avx512bw")
}

#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_skylake() -> bool {
    false
}

// Feature set supported by Ice Lake, Tiger Lake, Rocket Lake, Zen 4, and Zen 5
#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    all(
        target_feature = "avx512vpopcntdq",
        target_feature = "avx512ifma",
        target_feature = "avx512vbmi",
        target_feature = "avx512vnni",
        target_feature = "avx512vbmi2",
        target_feature = "avx512bitalg",
        target_feature = "vpclmulqdq",
        target_feature = "gfni",
        target_feature = "vaes"
    )
))]
#[must_use]
#[inline]
pub fn has_avx512_znver4() -> bool {
    has_avx512_skylake()
}

#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    not(all(
        target_feature = "avx512vpopcntdq",
        target_feature = "avx512ifma",
        target_feature = "avx512vbmi",
        target_feature = "avx512vnni",
        target_feature = "avx512vbmi2",
        target_feature = "avx512bitalg",
        target_feature = "vpclmulqdq",
        target_feature = "gfni",
        target_feature = "vaes"
    ))
))]
#[must_use]
#[inline]
pub fn has_avx512_znver4() -> bool {
    has_avx512_skylake()
        && is_x86_feature_detected!("avx512vpopcntdq")
        && is_x86_feature_detected!("avx512ifma")
        && is_x86_feature_detected!("avx512vbmi")
        && is_x86_feature_detected!("avx512vnni")
        && is_x86_feature_detected!("avx512vbmi2")
        && is_x86_feature_detected!("avx512bitalg")
        && is_x86_feature_detected!("vpclmulqdq")
        && is_x86_feature_detected!("gfni")
        && is_x86_feature_detected!("vaes")
}

#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_znver4() -> bool {
    false
}

// Feature set supported by Zen 5.
// We primarily need a separate Zen 5 set to enable some functions that are
// performant on Zen 5's full-width AVX-512 pipeline, but not on Zen 4's half-width pipeline.
#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    target_feature = "avx512vp2intersect"
))]
#[must_use]
#[inline]
pub fn has_avx512_znver5() -> bool {
    has_avx512_znver4()
}

#[cfg(all(
    target_arch = "x86_64",
    feature = "avx512",
    not(target_feature = "avx512vp2intersect")
))]
#[must_use]
#[inline]
pub fn has_avx512_znver5() -> bool {
    has_avx512_znver4() && is_x86_feature_detected!("avx512vp2intersect")
}

#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
    clippy::missing_const_for_fn,
    reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_znver5() -> bool {
    false
}