Commit 8e5c00fe authored by Ronald S. Bultje's avatar Ronald S. Bultje

Ensure all tile workers are parked before finishing frame

Otherwise a pathological condition can start the next frame while some
related variables are still being read. Fixes #43.
parent e293c396
......@@ -2589,10 +2589,7 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
// signal available tasks to worker threads
int num_tasks;
const uint64_t all_mask = ~0ULL >> (64 - f->n_tc);
pthread_mutex_lock(&f->tile_thread.lock);
while (f->tile_thread.available != all_mask)
pthread_cond_wait(&f->tile_thread.icond, &f->tile_thread.lock);
assert(!f->tile_thread.tasks_left);
if (f->frame_thread.pass == 1 || f->n_tc >= f->frame_hdr.tiling.cols) {
// we can (or in fact, if >, we need to) do full tile decoding.
......@@ -2635,6 +2632,12 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
progress_plane_type);
}
}
const uint64_t all_mask = ~0ULL >> (64 - f->n_tc);
pthread_mutex_lock(&f->tile_thread.lock);
while (f->tile_thread.available != all_mask)
pthread_cond_wait(&f->tile_thread.icond, &f->tile_thread.lock);
pthread_mutex_unlock(&f->tile_thread.lock);
}
if (f->frame_thread.pass <= 1 && f->frame_hdr.refresh_context) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment