*: returning &mut Self from setters was an awful idea
Deref breaks things.
This commit is contained in:
@ -19,9 +19,9 @@ impl Audio {
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(&mut self, format: format::Sample, samples: usize, layout: ChannelLayout) {
|
||||
self.set_format(format)
|
||||
.set_samples(samples)
|
||||
.set_channel_layout(layout);
|
||||
self.set_format(format);
|
||||
self.set_samples(samples);
|
||||
self.set_channel_layout(layout);
|
||||
|
||||
av_frame_get_buffer(self.as_mut_ptr(), 0);
|
||||
}
|
||||
@ -58,12 +58,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_format(&mut self, value: format::Sample) -> &mut Self {
|
||||
pub fn set_format(&mut self, value: format::Sample) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).format = mem::transmute::<AVSampleFormat, c_int>(value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -74,12 +72,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
av_frame_set_channel_layout(self.as_mut_ptr(), value.bits() as int64_t);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -90,12 +86,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_channels(&mut self, value: u16) -> &mut Self {
|
||||
pub fn set_channels(&mut self, value: u16) {
|
||||
unsafe {
|
||||
av_frame_set_channels(self.as_mut_ptr(), value as c_int);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -106,12 +100,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_rate(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_rate(&mut self, value: u32) {
|
||||
unsafe {
|
||||
av_frame_set_sample_rate(self.as_mut_ptr(), value as c_int);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -122,12 +114,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_samples(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_samples(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).nb_samples = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -89,14 +89,14 @@ impl Frame {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pts(&mut self, value: Option<i64>) -> &mut Self {
|
||||
#[inline]
|
||||
pub fn set_pts(&mut self, value: Option<i64>) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pts = value.unwrap_or(AV_NOPTS_VALUE);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn timestamp(&self) -> Option<i64> {
|
||||
unsafe {
|
||||
match av_frame_get_best_effort_timestamp(self.as_ptr()) {
|
||||
@ -106,32 +106,35 @@ impl Frame {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn quality(&self) -> usize {
|
||||
unsafe {
|
||||
(*self.as_ptr()).quality as usize
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> Flags {
|
||||
unsafe {
|
||||
Flags::from_bits_truncate((*self.as_ptr()).flags)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn metadata(&self) -> DictionaryRef {
|
||||
unsafe {
|
||||
DictionaryRef::wrap(av_frame_get_metadata(self.as_ptr()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_metadata(&mut self, value: Dictionary) -> &mut Self {
|
||||
#[inline]
|
||||
pub fn set_metadata(&mut self, value: Dictionary) {
|
||||
unsafe {
|
||||
av_frame_set_metadata(self.as_mut_ptr(), value.disown());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn side_data(&self, kind: side_data::Type) -> Option<SideData> {
|
||||
unsafe {
|
||||
let ptr = av_frame_get_side_data(self.as_ptr(), kind.into());
|
||||
|
@ -22,9 +22,9 @@ impl Video {
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(&mut self, format: format::Pixel, width: u32, height: u32) {
|
||||
self.set_format(format)
|
||||
.set_width(width)
|
||||
.set_height(height);
|
||||
self.set_format(format);
|
||||
self.set_width(width);
|
||||
self.set_height(height);
|
||||
|
||||
av_frame_get_buffer(self.as_mut_ptr(), 32);
|
||||
}
|
||||
@ -61,12 +61,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_format(&mut self, value: format::Pixel) -> &mut Self {
|
||||
pub fn set_format(&mut self, value: format::Pixel) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).format = mem::transmute::<AVPixelFormat, c_int>(value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -77,12 +75,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_kind(&mut self, value: picture::Type) -> &mut Self {
|
||||
pub fn set_kind(&mut self, value: picture::Type) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pict_type = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -114,12 +110,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_width(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_width(&mut self, value: u32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).width = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -130,12 +124,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_height(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_height(&mut self, value: u32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).height = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -146,12 +138,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_space(&mut self, value: color::Space) -> &mut Self {
|
||||
pub fn set_color_space(&mut self, value: color::Space) {
|
||||
unsafe {
|
||||
av_frame_set_colorspace(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -162,12 +152,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_range(&mut self, value: color::Range) -> &mut Self {
|
||||
pub fn set_color_range(&mut self, value: color::Range) {
|
||||
unsafe {
|
||||
av_frame_set_color_range(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -178,12 +166,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) -> &mut Self {
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_primaries = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -194,12 +180,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) -> &mut Self {
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_trc = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
Reference in New Issue
Block a user