*: make internal pointer handling safer
This commit is contained in:
@ -17,7 +17,7 @@ impl Video {
|
||||
unsafe {
|
||||
let mut got: c_int = 0;
|
||||
|
||||
match avcodec_decode_video2(self.ptr, out.ptr, &mut got, &packet.val) {
|
||||
match avcodec_decode_video2(self.as_mut_ptr(), out.as_mut_ptr(), &mut got, packet.as_ptr()) {
|
||||
e if e < 0 => Err(Error::from(e)),
|
||||
_ => Ok(got != 0)
|
||||
}
|
||||
@ -26,103 +26,103 @@ impl Video {
|
||||
|
||||
pub fn width(&self) -> u32 {
|
||||
unsafe {
|
||||
(*self.ptr).width as u32
|
||||
(*self.as_ptr()).width as u32
|
||||
}
|
||||
}
|
||||
|
||||
pub fn height(&self) -> u32 {
|
||||
unsafe {
|
||||
(*self.ptr).height as u32
|
||||
(*self.as_ptr()).height as u32
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format(&self) -> format::Pixel {
|
||||
unsafe {
|
||||
format::Pixel::from((*self.ptr).pix_fmt)
|
||||
format::Pixel::from((*self.as_ptr()).pix_fmt)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_format(&mut self, value: format::Pixel) {
|
||||
unsafe {
|
||||
(*self.ptr).pix_fmt = value.into();
|
||||
(*self.as_mut_ptr()).pix_fmt = value.into();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_b_frames(&self) -> bool {
|
||||
unsafe {
|
||||
(*self.ptr).has_b_frames != 0
|
||||
(*self.as_ptr()).has_b_frames != 0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn aspect_ratio(&self) -> Rational {
|
||||
unsafe {
|
||||
Rational((*self.ptr).sample_aspect_ratio)
|
||||
Rational((*self.as_ptr()).sample_aspect_ratio)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn color_space(&self) -> color::Space {
|
||||
unsafe {
|
||||
color::Space::from((*self.ptr).colorspace)
|
||||
color::Space::from((*self.as_ptr()).colorspace)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn color_range(&self) -> color::Range {
|
||||
unsafe {
|
||||
color::Range::from((*self.ptr).color_range)
|
||||
color::Range::from((*self.as_ptr()).color_range)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn color_primaries(&self) -> color::Primaries {
|
||||
unsafe {
|
||||
color::Primaries::from((*self.ptr).color_primaries)
|
||||
color::Primaries::from((*self.as_ptr()).color_primaries)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn color_transfer_characteristic(&self) -> color::TransferCharacteristic {
|
||||
unsafe {
|
||||
color::TransferCharacteristic::from((*self.ptr).color_trc)
|
||||
color::TransferCharacteristic::from((*self.as_ptr()).color_trc)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn chroma_location(&self) -> chroma::Location {
|
||||
unsafe {
|
||||
chroma::Location::from((*self.ptr).chroma_sample_location)
|
||||
chroma::Location::from((*self.as_ptr()).chroma_sample_location)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slice_count(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.ptr).slice_count = value as c_int;
|
||||
(*self.as_mut_ptr()).slice_count = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slice_flags(&mut self, value: slice::Flags) {
|
||||
unsafe {
|
||||
(*self.ptr).slice_flags = value.bits();
|
||||
(*self.as_mut_ptr()).slice_flags = value.bits();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn skip_top(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.ptr).skip_top = value as c_int;
|
||||
(*self.as_mut_ptr()).skip_top = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn skip_bottom(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.ptr).skip_bottom = value as c_int;
|
||||
(*self.as_mut_ptr()).skip_bottom = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn references(&self) -> usize {
|
||||
unsafe {
|
||||
(*self.ptr).refs as usize
|
||||
(*self.as_ptr()).refs as usize
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_field_order(&mut self, value: FieldOrder) {
|
||||
unsafe {
|
||||
(*self.ptr).field_order = value.into();
|
||||
(*self.as_mut_ptr()).field_order = value.into();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user