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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use super::Vector;
use ffi::*;
pub struct Filter {
ptr: *mut SwsFilter,
}
impl Filter {
pub unsafe fn as_ptr(&self) -> *const SwsFilter {
self.ptr as *const _
}
pub unsafe fn as_mut_ptr(&mut self) -> *mut SwsFilter {
self.ptr
}
}
impl Filter {
pub fn get(
luma_g_blur: f32,
chroma_g_blur: f32,
luma_sharpen: f32,
chroma_sharpen: f32,
chroma_h_shift: f32,
chroma_v_shift: f32,
) -> Self {
unsafe {
Filter {
ptr: sws_getDefaultFilter(
luma_g_blur,
chroma_g_blur,
luma_sharpen,
chroma_sharpen,
chroma_h_shift,
chroma_v_shift,
0,
),
}
}
}
pub fn new() -> Self {
Self::get(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
}
pub fn luma_horizontal(&self) -> Vector {
unsafe { Vector::wrap((*self.as_ptr()).lumH) }
}
pub fn luma_horizontal_mut(&mut self) -> Vector {
unsafe { Vector::wrap((*self.as_mut_ptr()).lumH) }
}
pub fn luma_vertical(&self) -> Vector {
unsafe { Vector::wrap((*self.as_ptr()).lumV) }
}
pub fn luma_vertical_mut(&mut self) -> Vector {
unsafe { Vector::wrap((*self.as_mut_ptr()).lumV) }
}
pub fn chroma_horizontal(&self) -> Vector {
unsafe { Vector::wrap((*self.as_ptr()).lumV) }
}
pub fn chroma_horizontal_mut(&mut self) -> Vector {
unsafe { Vector::wrap((*self.as_mut_ptr()).lumV) }
}
pub fn chroma_vertical(&self) -> Vector {
unsafe { Vector::wrap((*self.as_ptr()).lumV) }
}
pub fn chroma_vertical_mut(&mut self) -> Vector {
unsafe { Vector::wrap((*self.as_mut_ptr()).lumV) }
}
}
impl Default for Filter {
fn default() -> Self {
Self::new()
}
}
impl Drop for Filter {
fn drop(&mut self) {
unsafe {
sws_freeFilter(self.as_mut_ptr());
}
}
}