codec/picture: change width and height to u32
This commit is contained in:
parent
18d91a9dd9
commit
f0b11a960a
@ -10,16 +10,16 @@ use ::Error;
|
|||||||
pub struct Picture<'a> {
|
pub struct Picture<'a> {
|
||||||
pub ptr: *mut AVPicture,
|
pub ptr: *mut AVPicture,
|
||||||
|
|
||||||
pub format: format::Pixel,
|
format: format::Pixel,
|
||||||
pub width: usize,
|
width: u32,
|
||||||
pub height: usize,
|
height: u32,
|
||||||
|
|
||||||
_own: bool,
|
_own: bool,
|
||||||
_marker: PhantomData<&'a ()>,
|
_marker: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Picture<'a> {
|
impl<'a> Picture<'a> {
|
||||||
pub fn size(format: format::Pixel, width: usize, height: usize) -> Result<usize, Error> {
|
pub fn size(format: format::Pixel, width: u32, height: u32) -> Result<usize, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
match avpicture_get_size(format.into(), width as c_int, height as c_int) {
|
match avpicture_get_size(format.into(), width as c_int, height as c_int) {
|
||||||
v if v >= 0 => Ok(v as usize),
|
v if v >= 0 => Ok(v as usize),
|
||||||
@ -28,7 +28,7 @@ impl<'a> Picture<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(format: format::Pixel, width: usize, height: usize) -> Result<Self, Error> {
|
pub fn new(format: format::Pixel, width: u32, height: u32) -> Result<Self, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = av_malloc(mem::size_of::<AVPicture>() as size_t) as *mut AVPicture;
|
let ptr = av_malloc(mem::size_of::<AVPicture>() as size_t) as *mut AVPicture;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ impl<'a> Picture<'a> {
|
|||||||
format: format,
|
format: format,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
|
|
||||||
_own: true,
|
_own: true,
|
||||||
_marker: PhantomData
|
_marker: PhantomData
|
||||||
}),
|
}),
|
||||||
@ -49,19 +49,31 @@ impl<'a> Picture<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrap(ptr: *mut AVPicture, format: format::Pixel, width: usize, height: usize) -> Self {
|
pub fn wrap(ptr: *mut AVPicture, format: format::Pixel, width: u32, height: u32) -> Self {
|
||||||
Picture {
|
Picture {
|
||||||
ptr: ptr,
|
ptr: ptr,
|
||||||
|
|
||||||
format: format,
|
format: format,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
|
|
||||||
_own: false,
|
_own: false,
|
||||||
_marker: PhantomData
|
_marker: PhantomData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn format(&self) -> format::Pixel {
|
||||||
|
self.format
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn width(&self) -> u32 {
|
||||||
|
self.width
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn height(&self) -> u32 {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
pub fn layout(&self, out: &mut [u8]) -> Result<usize, Error> {
|
pub fn layout(&self, out: &mut [u8]) -> Result<usize, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
match avpicture_layout(self.ptr, self.format.into(), self.width as c_int, self.height as c_int, out.as_mut_ptr(), out.len() as c_int) {
|
match avpicture_layout(self.ptr, self.format.into(), self.width as c_int, self.height as c_int, out.as_mut_ptr(), out.len() as c_int) {
|
||||||
@ -71,7 +83,7 @@ impl<'a> Picture<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout_as(&self, format: format::Pixel, width: usize, height: usize, out: &mut [u8]) -> Result<usize, Error> {
|
pub fn layout_as(&self, format: format::Pixel, width: u32, height: u32, out: &mut [u8]) -> Result<usize, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
match avpicture_layout(self.ptr, format.into(), width as c_int, height as c_int, out.as_mut_ptr(), out.len() as c_int) {
|
match avpicture_layout(self.ptr, format.into(), width as c_int, height as c_int, out.as_mut_ptr(), out.len() as c_int) {
|
||||||
s if s >= 0 => Ok(s as usize),
|
s if s >= 0 => Ok(s as usize),
|
||||||
@ -80,7 +92,7 @@ impl<'a> Picture<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn crop(&mut self, source: &Picture, top: usize, left: usize) -> Result<(), Error> {
|
pub fn crop(&mut self, source: &Picture, top: u32, left: u32) -> Result<(), Error> {
|
||||||
if self.format != source.format {
|
if self.format != source.format {
|
||||||
return Err(Error::new(AVERROR_BUG));
|
return Err(Error::new(AVERROR_BUG));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user