util/frame/video: add more inline attributes

This commit is contained in:
meh 2015-10-29 06:04:21 +01:00
parent d2b6557fbc
commit 62ebd122ac

View File

@ -221,6 +221,7 @@ impl Video {
} }
} }
#[inline]
pub fn planes(&self) -> usize { pub fn planes(&self) -> usize {
for i in 0 .. 8 { for i in 0 .. 8 {
unsafe { unsafe {
@ -267,6 +268,7 @@ impl Video {
} }
} }
#[inline]
pub fn data(&self, index: usize) -> &[u8] { pub fn data(&self, index: usize) -> &[u8] {
if index >= self.planes() { if index >= self.planes() {
panic!("out of bounds"); panic!("out of bounds");
@ -278,6 +280,7 @@ impl Video {
} }
} }
#[inline]
pub fn data_mut(&mut self, index: usize) -> &mut [u8] { pub fn data_mut(&mut self, index: usize) -> &mut [u8] {
if index >= self.planes() { if index >= self.planes() {
panic!("out of bounds"); panic!("out of bounds");
@ -293,18 +296,21 @@ impl Video {
impl Deref for Video { impl Deref for Video {
type Target = Frame; type Target = Frame;
#[inline]
fn deref(&self) -> &Frame { fn deref(&self) -> &Frame {
&self.0 &self.0
} }
} }
impl DerefMut for Video { impl DerefMut for Video {
#[inline]
fn deref_mut(&mut self) -> &mut Frame { fn deref_mut(&mut self) -> &mut Frame {
&mut self.0 &mut self.0
} }
} }
impl Clone for Video { impl Clone for Video {
#[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
let mut cloned = Video::new(self.format(), self.width(), self.height()); let mut cloned = Video::new(self.format(), self.width(), self.height());
cloned.clone_from(self); cloned.clone_from(self);
@ -312,6 +318,7 @@ impl Clone for Video {
cloned cloned
} }
#[inline]
fn clone_from(&mut self, source: &Self) { fn clone_from(&mut self, source: &Self) {
unsafe { unsafe {
av_frame_copy(self.as_mut_ptr(), source.as_ptr()); av_frame_copy(self.as_mut_ptr(), source.as_ptr());
@ -321,6 +328,7 @@ impl Clone for Video {
} }
impl From<Frame> for Video { impl From<Frame> for Video {
#[inline]
fn from(frame: Frame) -> Self { fn from(frame: Frame) -> Self {
Video(frame) Video(frame)
} }