diff --git a/src/util/frame/video.rs b/src/util/frame/video.rs index 9fe2f88..3bb584b 100644 --- a/src/util/frame/video.rs +++ b/src/util/frame/video.rs @@ -13,10 +13,24 @@ use super::Frame; pub struct Video(Frame); impl Video { - pub fn new() -> Self { + pub fn empty() -> Self { Video(Frame::new()) } + pub fn new(format: format::Pixel, width: u32, height: u32) -> Self { + unsafe { + let mut frame = Video(Frame::new()); + + frame.set_format(format); + frame.set_width(width); + frame.set_height(height); + + av_frame_get_buffer(frame.ptr, 1); + + frame + } + } + pub fn picture(&self) -> Picture { Picture::wrap(self.ptr as *mut AVPicture, self.format(), self.width(), self.height()) } @@ -32,6 +46,12 @@ impl Video { } } + pub fn set_format(&mut self, value: format::Pixel) { + unsafe { + (*self.ptr).format = mem::transmute::(value.into()); + } + } + pub fn kind(&self) -> picture::Type { unsafe { picture::Type::from((*self.ptr).pict_type)