1pub mod encoder;
2pub use self::encoder::Encoder;
3
4pub mod video;
5pub use self::video::Encoder as Video;
6
7pub mod audio;
8pub use self::audio::Encoder as Audio;
9
10pub mod subtitle;
11pub use self::subtitle::Encoder as Subtitle;
12
13pub mod motion_estimation;
14pub use self::motion_estimation::MotionEstimation;
15
16#[cfg(not(feature = "ffmpeg_5_0"))]
17pub mod prediction;
18#[cfg(not(feature = "ffmpeg_5_0"))]
19pub use self::prediction::Prediction;
20
21pub mod comparison;
22pub use self::comparison::Comparison;
23
24pub mod decision;
25pub use self::decision::Decision;
26
27use std::ffi::CString;
28
29use codec::Context;
30use codec::Id;
31use ffi::*;
32use Codec;
33
34pub fn new() -> Encoder {
35 Context::new().encoder()
36}
37
38pub fn find(id: Id) -> Option<Codec> {
39 unsafe {
40 // We get a clippy warning in 4.4 but not in 5.0 and newer, so we allow that cast to not complicate the code
41 #[allow(clippy::unnecessary_cast)]
42 let ptr: *mut {unknown} = avcodec_find_encoder(id.into()) as *mut AVCodec;
43
44 if ptr.is_null() {
45 None
46 } else {
47 Some(Codec::wrap(ptr))
48 }
49 }
50}
51
52pub fn find_by_name(name: &str) -> Option<Codec> {
53 unsafe {
54 let name: CString = CString::new(name).unwrap();
55 #[allow(clippy::unnecessary_cast)]
56 let ptr: *mut {unknown} = avcodec_find_encoder_by_name(name.as_ptr()) as *mut AVCodec;
57
58 if ptr.is_null() {
59 None
60 } else {
61 Some(Codec::wrap(ptr))
62 }
63 }
64}
65