util/frame/video: rename new to empty and make new allocate the buffers
This commit is contained in:
parent
049e8a6cdd
commit
b57bff3e61
@ -13,10 +13,24 @@ use super::Frame;
|
|||||||
pub struct Video(Frame);
|
pub struct Video(Frame);
|
||||||
|
|
||||||
impl Video {
|
impl Video {
|
||||||
pub fn new() -> Self {
|
pub fn empty() -> Self {
|
||||||
Video(Frame::new())
|
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 {
|
pub fn picture(&self) -> Picture {
|
||||||
Picture::wrap(self.ptr as *mut AVPicture, self.format(), self.width(), self.height())
|
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::<AVPixelFormat, c_int>(value.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn kind(&self) -> picture::Type {
|
pub fn kind(&self) -> picture::Type {
|
||||||
unsafe {
|
unsafe {
|
||||||
picture::Type::from((*self.ptr).pict_type)
|
picture::Type::from((*self.ptr).pict_type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user