util/frame: only Frame needs to be Send
This commit is contained in:
parent
e188c69030
commit
32bf1b37ac
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -261,8 +261,6 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Video { }
|
||||
|
||||
impl Deref for Video {
|
||||
type Target = Frame;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user