codec/capabilities: add Capabilities and getter

This commit is contained in:
meh 2015-08-28 21:20:40 +02:00
parent 5fff2ab123
commit e8db20c86b
3 changed files with 34 additions and 4 deletions

25
src/codec/capabilities.rs Normal file
View File

@ -0,0 +1,25 @@
use libc::c_uint;
use ffi::*;
bitflags! {
flags Capabilities: c_uint {
const DRAW_HORIZ_BAND = CODEC_CAP_DRAW_HORIZ_BAND,
const DR1 = CODEC_CAP_DR1,
const TRUNCATED = CODEC_CAP_TRUNCATED,
const HWACCEL = CODEC_CAP_HWACCEL,
const DELAY = CODEC_CAP_DELAY,
const SMALL_LAST_FRAME = CODEC_CAP_SMALL_LAST_FRAME,
const HWACCEL_VDPAU = CODEC_CAP_HWACCEL_VDPAU,
const SUBFRAMES = CODEC_CAP_SUBFRAMES,
const EXPERIMENTAL = CODEC_CAP_EXPERIMENTAL,
const CHANNEL_CONF = CODEC_CAP_CHANNEL_CONF,
const NEG_LINESIZES = CODEC_CAP_NEG_LINESIZES,
const FRAME_THREADS = CODEC_CAP_FRAME_THREADS,
const SLICE_THREADS = CODEC_CAP_SLICE_THREADS,
const PARAM_CHANGE = CODEC_CAP_PARAM_CHANGE,
const AUTO_THREADS = CODEC_CAP_AUTO_THREADS,
const VARIABLE_FRAME_SIZE = CODEC_CAP_VARIABLE_FRAME_SIZE,
const INTRA_ONLY = CODEC_CAP_INTRA_ONLY,
const LOSSLESS = CODEC_CAP_LOSSLESS,
}
}

View File

@ -3,7 +3,7 @@ use std::ffi::CStr;
use std::str::from_utf8_unchecked; use std::str::from_utf8_unchecked;
use ffi::*; use ffi::*;
use super::{Id, Context, Video, Audio}; use super::{Id, Context, Video, Audio, Capabilities};
use ::{Error, media}; use ::{Error, media};
use ::codec::context::Opened; use ::codec::context::Opened;
@ -90,13 +90,15 @@ impl<'a> Codec<'a> {
} }
} }
// capabilities
pub fn max_lowres(&self) -> i32 { pub fn max_lowres(&self) -> i32 {
unsafe { unsafe {
av_codec_get_max_lowres(self.as_ptr()) av_codec_get_max_lowres(self.as_ptr())
} }
} }
// profiles pub fn capabilities(&self) -> Capabilities {
unsafe {
Capabilities::from_bits_truncate((*self.as_ptr()).capabilities as u32)
}
}
} }

View File

@ -12,6 +12,9 @@ pub mod discard;
pub mod context; pub mod context;
pub use self::context::Context; pub use self::context::Context;
pub mod capabilities;
pub use self::capabilities::Capabilities;
pub mod codec; pub mod codec;
pub mod video; pub mod video;