From e063da22a4b9bd2cbd6506f54e0d9f1c696bee49 Mon Sep 17 00:00:00 2001 From: meh Date: Fri, 14 Aug 2015 19:33:06 +0200 Subject: [PATCH] frame/side_data: add inline attributes --- src/util/frame/side_data.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index 8cc3722..669ff63 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -23,6 +23,7 @@ pub enum Type { } impl Type { + #[inline] pub fn name(&self) -> &'static str { unsafe { from_utf8_unchecked(CStr::from_ptr(av_frame_side_data_name((*self).into())).to_bytes()) @@ -31,6 +32,7 @@ impl Type { } impl From for Type { + #[inline(always)] fn from(value: AVFrameSideDataType) -> Self { match value { AV_FRAME_DATA_PANSCAN => Type::PanScan, @@ -49,6 +51,7 @@ impl From for Type { } impl Into for Type { + #[inline(always)] fn into(self) -> AVFrameSideDataType { match self { Type::PanScan => AV_FRAME_DATA_PANSCAN, @@ -73,32 +76,38 @@ pub struct SideData<'a> { } impl<'a> SideData<'a> { + #[inline(always)] pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self { SideData { ptr: ptr, _marker: PhantomData } } + #[inline(always)] pub unsafe fn as_ptr(&self) -> *const AVFrameSideData { self.ptr as *const _ } + #[inline(always)] pub unsafe fn as_mut_ptr(&mut self) -> *mut AVFrameSideData { self.ptr } } impl<'a> SideData<'a> { + #[inline] pub fn kind(&self) -> Type { unsafe { Type::from((*self.as_ptr()).kind) } } + #[inline] pub fn data(&self) -> &[u8] { unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) } } + #[inline] pub fn metadata(&self) -> Dictionary { unsafe { Dictionary::wrap((*self.as_ptr()).metadata)