From 56e7ffc0dbe44970a4d55ec2241824c67add9dd5 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Wed, 9 Mar 2022 13:43:25 -0800 Subject: Set f->n_tile_data to 0 in dav1d_decode_frame() Set f->n_tile_data to 0 after the dav1d_decode_frame_exit() call in dav1d_decode_frame(). dav1d_decode_frame_exit() unrefs every element in use in the f->tile array, so it is good to set f->n_tile_data to 0 to indicate that no elements are in use. We are already doing this after all other dav1d_decode_frame_exit() calls. NOTE: It is tempting to have dav1d_decode_frame_exit() itself set f->n_tile_data to 0. I did not do that in this merge request, because the following is a common pattern: dav1d_decode_frame_exit(f, error); f->n_tile_data = 0; pthread_cond_signal(&f->task_thread.cond); corresponding to the waiting code: while (f->n_tile_data > 0) pthread_cond_wait(&f->task_thread.cond, &c->task_thread.lock); I wonder if f->n_tile_data is set to 0 outside dav1d_decode_frame_exit() to make clear the association of f->n_tile_data with the condition variable f->task_thread.cond. --- src/decode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/decode.c b/src/decode.c index bd13014..13d5706 100644 --- a/src/decode.c +++ b/src/decode.c @@ -3463,6 +3463,7 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) { } } dav1d_decode_frame_exit(f, res); + f->n_tile_data = 0; return res; } -- cgit v1.2.3