From de76d0a2940dec699428a6adb358911c991dd94e Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Mon, 19 May 2014 18:31:01 +0300 Subject: [PATCH] Don't add dependency to the above LCU in wavefront if it's not necessary. - The top-right LCU already has dependency to the top LCU. --- src/encoder.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index fe1905b5..f99ec87d 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -1350,13 +1350,17 @@ static void encoder_state_encode_leaf(encoder_state * const encoder_state) { encoder_state->tile->wf_jobs[lcu->id] = threadqueue_submit(encoder_state->encoder_control->threadqueue, worker_encoder_state_encode_lcu, (void*)lcu, 1, job_description); if (encoder_state->tile->wf_jobs[lcu->id]) { if (lcu->position.x > 0) { + // Wait for the LCU on the left. threadqueue_job_dep_add(encoder_state->tile->wf_jobs[lcu->id], encoder_state->tile->wf_jobs[lcu->id - 1]); } if (lcu->position.y > 0) { - threadqueue_job_dep_add(encoder_state->tile->wf_jobs[lcu->id], encoder_state->tile->wf_jobs[lcu->id - encoder_state->tile->cur_pic->width_in_lcu]); - } - if (lcu->position.y > 0 && lcu->position.x < encoder_state->tile->cur_pic->width_in_lcu - 1) { - threadqueue_job_dep_add(encoder_state->tile->wf_jobs[lcu->id], encoder_state->tile->wf_jobs[lcu->id - encoder_state->tile->cur_pic->width_in_lcu + 1]); + if (lcu->position.x < encoder_state->tile->cur_pic->width_in_lcu - 1) { + // Wait for the LCU to the top-right of this one. + threadqueue_job_dep_add(encoder_state->tile->wf_jobs[lcu->id], encoder_state->tile->wf_jobs[lcu->id - encoder_state->tile->cur_pic->width_in_lcu + 1]); + } else { + // If there is no top-right LCU, wait for the one above. + threadqueue_job_dep_add(encoder_state->tile->wf_jobs[lcu->id], encoder_state->tile->wf_jobs[lcu->id - encoder_state->tile->cur_pic->width_in_lcu]); + } } threadqueue_job_unwait_job(encoder_state->encoder_control->threadqueue, encoder_state->tile->wf_jobs[lcu->id]); }