Skip to main content

vmaf_head_sys/
lib.rs

1//! Low-level FFI bindings to Netflix VMAF.
2//!
3//! All functions that call into libvmaf are unsafe. Consider using a safe
4//! wrapper crate for application code.
5
6#![allow(non_upper_case_globals)]
7#![allow(non_camel_case_types)]
8#![allow(non_snake_case)]
9#![allow(dead_code)]
10#![allow(clippy::all)]
11
12mod bindings;
13pub use bindings::*;
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18
19    #[test]
20    fn test_api_version_constants() {
21        assert!(VMAF_API_VERSION_MAJOR > 0);
22    }
23
24    #[test]
25    fn test_vmaf_version() {
26        unsafe {
27            let version = vmaf_version();
28            assert!(!version.is_null());
29            assert!(!std::ffi::CStr::from_ptr(version).to_bytes().is_empty());
30        }
31    }
32
33    #[test]
34    fn test_context_lifecycle() {
35        unsafe {
36            let mut context = std::ptr::null_mut();
37            let config = VmafConfiguration {
38                log_level: VmafLogLevel_VMAF_LOG_LEVEL_NONE,
39                n_threads: 0,
40                n_subsample: 1,
41                cpumask: 0,
42                gpumask: 0,
43            };
44
45            assert_eq!(vmaf_init(&mut context, config), 0);
46            assert!(!context.is_null());
47            assert_eq!(vmaf_close(context), 0);
48        }
49    }
50}