util/frame: only Frame needs to be Send

This commit is contained in:
meh 2015-06-09 23:47:10 +02:00
parent e188c69030
commit 32bf1b37ac
3 changed files with 31 additions and 7 deletions

View File

@ -127,7 +127,7 @@ impl Audio {
1
}
else {
self.samples()
self.channels() as usize
}
}
@ -162,9 +162,35 @@ impl Audio {
mem::size_of::<T>() * self.samples())
}
}
}
unsafe impl Send for Audio { }
pub fn data(&self) -> Vec<&[u8]> {
let mut result = Vec::new();
unsafe {
for i in 0 .. self.planes() {
result.push(slice::from_raw_parts(
(*self.as_ptr()).data[i],
(*self.as_ptr()).linesize[0] as usize));
}
}
result
}
pub fn data_mut(&mut self) -> Vec<&mut [u8]> {
let mut result = Vec::new();
unsafe {
for i in 0 .. self.planes() {
result.push(slice::from_raw_parts_mut(
(*self.as_mut_ptr()).data[i],
(*self.as_ptr()).linesize[0] as usize));
}
}
result
}
}
impl Deref for Audio {
type Target = Frame;

View File

@ -31,6 +31,8 @@ pub struct Frame {
_own: bool,
}
unsafe impl Send for Frame { }
impl Frame {
pub unsafe fn wrap(ptr: *mut AVFrame) -> Self {
Frame { ptr: ptr, _own: false }
@ -149,8 +151,6 @@ impl Frame {
}
}
unsafe impl Send for Frame { }
impl Drop for Frame {
fn drop(&mut self) {
unsafe {

View File

@ -261,8 +261,6 @@ impl Video {
}
}
unsafe impl Send for Video { }
impl Deref for Video {
type Target = Frame;