*: refactor setters to return self
This commit is contained in:
@ -22,9 +22,9 @@ impl Video {
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(&mut self, format: format::Pixel, width: u32, height: u32) {
|
||||
self.set_format(format);
|
||||
self.set_width(width);
|
||||
self.set_height(height);
|
||||
self.set_format(format)
|
||||
.set_width(width)
|
||||
.set_height(height);
|
||||
|
||||
av_frame_get_buffer(self.as_mut_ptr(), 32);
|
||||
}
|
||||
@ -61,10 +61,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_format(&mut self, value: format::Pixel) {
|
||||
pub fn set_format(&mut self, value: format::Pixel) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).format = mem::transmute::<AVPixelFormat, c_int>(value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -75,10 +77,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_kind(&mut self, value: picture::Type) {
|
||||
pub fn set_kind(&mut self, value: picture::Type) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pict_type = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -110,10 +114,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_width(&mut self, value: u32) {
|
||||
pub fn set_width(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).width = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -124,10 +130,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_height(&mut self, value: u32) {
|
||||
pub fn set_height(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).height = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -138,10 +146,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_space(&mut self, value: color::Space) {
|
||||
pub fn set_color_space(&mut self, value: color::Space) -> &mut Self {
|
||||
unsafe {
|
||||
av_frame_set_colorspace(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -152,10 +162,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_range(&mut self, value: color::Range) {
|
||||
pub fn set_color_range(&mut self, value: color::Range) -> &mut Self {
|
||||
unsafe {
|
||||
av_frame_set_color_range(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -166,10 +178,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) {
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_primaries = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -180,10 +194,12 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) {
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_trc = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
Reference in New Issue
Block a user