diff --git a/Cargo.toml b/Cargo.toml index 6011300..d97319b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,10 @@ software-scaling = ["ffmpeg-sys/swscale", "codec"] libc = "0.1" bitflags = "0.1" +[dependencies.image] +version = "*" +optional = true + [dependencies.ffmpeg-sys] version = "2.7.0" diff --git a/src/lib.rs b/src/lib.rs index 3d24df1..f39b40b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ extern crate libc; extern crate ffmpeg_sys as ffi; #[macro_use] extern crate bitflags; +#[cfg(feature = "image")] extern crate image; pub mod util; pub use util::error::Error; diff --git a/src/util/frame/video.rs b/src/util/frame/video.rs index 871e48d..7d23b87 100644 --- a/src/util/frame/video.rs +++ b/src/util/frame/video.rs @@ -293,3 +293,24 @@ impl Clone for Video { pub trait Component { fn is_valid(format: format::Pixel) -> bool; } + +#[cfg(feature = "image")] +impl Component for ::image::Luma { + fn is_valid(format: format::Pixel) -> bool { + format == format::Pixel::GRAY8 + } +} + +#[cfg(feature = "image")] +impl Component for ::image::Rgb { + fn is_valid(format: format::Pixel) -> bool { + format == format::Pixel::RGB24 + } +} + +#[cfg(feature = "image")] +impl Component for ::image::Rgba { + fn is_valid(format: format::Pixel) -> bool { + format == format::Pixel::RGBA + } +}