Skip to content

Commit

Permalink
fn rav1d_open: Initialize c.state.frame_thread.out_delayed w/ `Mu…
Browse files Browse the repository at this point in the history
…tex::new` and `..Default::default()` rather than taking the lock.
  • Loading branch information
kkysen committed Jun 12, 2024
1 parent 72521fa commit 34d0cc4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::src::internal::Rav1dBitDepthDSPContext;
use crate::src::internal::Rav1dContext;
use crate::src::internal::Rav1dContextTaskThread;
use crate::src::internal::Rav1dContextTaskType;
use crate::src::internal::Rav1dContext_frame_thread;
use crate::src::internal::Rav1dFrameContext;
use crate::src::internal::Rav1dState;
use crate::src::internal::Rav1dTaskContext;
Expand Down Expand Up @@ -239,11 +240,17 @@ pub(crate) unsafe fn rav1d_open(c_out: &mut *const Rav1dContext, s: &Rav1dSettin
delayed_fg: Default::default(),
};
(*c).task_thread = Arc::new(ttd);
(*c).state.try_lock().unwrap().frame_thread.out_delayed = if n_fc > 1 {
(0..n_fc).map(|_| Default::default()).collect()
} else {
Box::new([])
};
(*c).state = Mutex::new(Rav1dState {
frame_thread: Rav1dContext_frame_thread {
out_delayed: if n_fc > 1 {
(0..n_fc).map(|_| Default::default()).collect()
} else {
Box::new([])
},
..Default::default()
},
..Default::default()
});
for fc in (*c).fc.iter_mut() {
fc.task_thread.finished = AtomicBool::new(true);
fc.task_thread.ttd = Arc::clone(&(*c).task_thread);
Expand Down

0 comments on commit 34d0cc4

Please sign in to comment.