diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2018-10-06 22:15:03 +0300 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2018-10-08 14:53:26 +0300 |
commit | 8e5c00fee92731a98998f935bb504d35bb4310c6 (patch) | |
tree | ff4944e36604b9492d5c7e6c2de9d9a0edd5853a /src/decode.c | |
parent | e293c3963ffe94490143353ab480f8477d0d52ef (diff) |
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.
Diffstat (limited to 'src/decode.c')
-rw-r--r-- | src/decode.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/decode.c b/src/decode.c index f5c3bac..90b5314 100644 --- a/src/decode.c +++ b/src/decode.c @@ -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) { |