1 | use ffi::*; |
2 | use libc::c_int; |
3 | |
4 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
5 | pub enum Comparison { |
6 | SAD, |
7 | SSE, |
8 | SATD, |
9 | DCT, |
10 | PSNR, |
11 | BIT, |
12 | RD, |
13 | ZERO, |
14 | VSAD, |
15 | VSSE, |
16 | NSSE, |
17 | W53, |
18 | W97, |
19 | DCTMAX, |
20 | DCT264, |
21 | CHROMA, |
22 | } |
23 | |
24 | impl From<c_int> for Comparison { |
25 | fn from(value: c_int) -> Comparison { |
26 | match value { |
27 | FF_CMP_SAD: i32 => Comparison::SAD, |
28 | FF_CMP_SSE: i32 => Comparison::SSE, |
29 | FF_CMP_SATD: i32 => Comparison::SATD, |
30 | FF_CMP_DCT: i32 => Comparison::DCT, |
31 | FF_CMP_PSNR: i32 => Comparison::PSNR, |
32 | FF_CMP_BIT: i32 => Comparison::BIT, |
33 | FF_CMP_RD: i32 => Comparison::RD, |
34 | FF_CMP_ZERO: i32 => Comparison::ZERO, |
35 | FF_CMP_VSAD: i32 => Comparison::VSAD, |
36 | FF_CMP_VSSE: i32 => Comparison::VSSE, |
37 | FF_CMP_NSSE: i32 => Comparison::NSSE, |
38 | FF_CMP_W53: i32 => Comparison::W53, |
39 | FF_CMP_W97: i32 => Comparison::W97, |
40 | FF_CMP_DCTMAX: i32 => Comparison::DCTMAX, |
41 | FF_CMP_DCT264: i32 => Comparison::DCT264, |
42 | FF_CMP_CHROMA: i32 => Comparison::CHROMA, |
43 | |
44 | _ => Comparison::ZERO, |
45 | } |
46 | } |
47 | } |
48 | |
49 | impl From<Comparison> for c_int { |
50 | fn from(value: Comparison) -> c_int { |
51 | match value { |
52 | Comparison::SAD => FF_CMP_SAD, |
53 | Comparison::SSE => FF_CMP_SSE, |
54 | Comparison::SATD => FF_CMP_SATD, |
55 | Comparison::DCT => FF_CMP_DCT, |
56 | Comparison::PSNR => FF_CMP_PSNR, |
57 | Comparison::BIT => FF_CMP_BIT, |
58 | Comparison::RD => FF_CMP_RD, |
59 | Comparison::ZERO => FF_CMP_ZERO, |
60 | Comparison::VSAD => FF_CMP_VSAD, |
61 | Comparison::VSSE => FF_CMP_VSSE, |
62 | Comparison::NSSE => FF_CMP_NSSE, |
63 | Comparison::W53 => FF_CMP_W53, |
64 | Comparison::W97 => FF_CMP_W97, |
65 | Comparison::DCTMAX => FF_CMP_DCTMAX, |
66 | Comparison::DCT264 => FF_CMP_DCT264, |
67 | Comparison::CHROMA => FF_CMP_CHROMA, |
68 | } |
69 | } |
70 | } |
71 | |