frame/side_data: add inline attributes
This commit is contained in:
parent
83d3156c62
commit
e063da22a4
@ -23,6 +23,7 @@ pub enum Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Type {
|
impl Type {
|
||||||
|
#[inline]
|
||||||
pub fn name(&self) -> &'static str {
|
pub fn name(&self) -> &'static str {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_utf8_unchecked(CStr::from_ptr(av_frame_side_data_name((*self).into())).to_bytes())
|
from_utf8_unchecked(CStr::from_ptr(av_frame_side_data_name((*self).into())).to_bytes())
|
||||||
@ -31,6 +32,7 @@ impl Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<AVFrameSideDataType> for Type {
|
impl From<AVFrameSideDataType> for Type {
|
||||||
|
#[inline(always)]
|
||||||
fn from(value: AVFrameSideDataType) -> Self {
|
fn from(value: AVFrameSideDataType) -> Self {
|
||||||
match value {
|
match value {
|
||||||
AV_FRAME_DATA_PANSCAN => Type::PanScan,
|
AV_FRAME_DATA_PANSCAN => Type::PanScan,
|
||||||
@ -49,6 +51,7 @@ impl From<AVFrameSideDataType> for Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Into<AVFrameSideDataType> for Type {
|
impl Into<AVFrameSideDataType> for Type {
|
||||||
|
#[inline(always)]
|
||||||
fn into(self) -> AVFrameSideDataType {
|
fn into(self) -> AVFrameSideDataType {
|
||||||
match self {
|
match self {
|
||||||
Type::PanScan => AV_FRAME_DATA_PANSCAN,
|
Type::PanScan => AV_FRAME_DATA_PANSCAN,
|
||||||
@ -73,32 +76,38 @@ pub struct SideData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SideData<'a> {
|
impl<'a> SideData<'a> {
|
||||||
|
#[inline(always)]
|
||||||
pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self {
|
pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self {
|
||||||
SideData { ptr: ptr, _marker: PhantomData }
|
SideData { ptr: ptr, _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub unsafe fn as_ptr(&self) -> *const AVFrameSideData {
|
pub unsafe fn as_ptr(&self) -> *const AVFrameSideData {
|
||||||
self.ptr as *const _
|
self.ptr as *const _
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVFrameSideData {
|
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVFrameSideData {
|
||||||
self.ptr
|
self.ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SideData<'a> {
|
impl<'a> SideData<'a> {
|
||||||
|
#[inline]
|
||||||
pub fn kind(&self) -> Type {
|
pub fn kind(&self) -> Type {
|
||||||
unsafe {
|
unsafe {
|
||||||
Type::from((*self.as_ptr()).kind)
|
Type::from((*self.as_ptr()).kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn data(&self) -> &[u8] {
|
pub fn data(&self) -> &[u8] {
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize)
|
slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn metadata(&self) -> Dictionary {
|
pub fn metadata(&self) -> Dictionary {
|
||||||
unsafe {
|
unsafe {
|
||||||
Dictionary::wrap((*self.as_ptr()).metadata)
|
Dictionary::wrap((*self.as_ptr()).metadata)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user