1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::marker::PhantomData;
use std::ptr::NonNull;
use vapoursynth_sys as ffi;
use crate::api::API;
#[derive(Debug, Clone, Copy)]
pub struct FrameContext<'a> {
handle: NonNull<ffi::VSFrameContext>,
_owner: PhantomData<&'a ()>,
}
impl<'a> FrameContext<'a> {
#[inline]
pub(crate) unsafe fn from_ptr(handle: *mut ffi::VSFrameContext) -> Self {
Self {
handle: NonNull::new_unchecked(handle),
_owner: PhantomData,
}
}
#[inline]
pub(crate) fn ptr(self) -> *mut ffi::VSFrameContext {
self.handle.as_ptr()
}
#[inline]
pub fn output_index(self) -> usize {
let index = unsafe { API::get_cached().get_output_index(self.handle.as_ptr()) };
debug_assert!(index >= 0);
index as _
}
}