Pass num_workers to enc_worker_hook() as arg2 Pass num_workers to enc_worker_hook() as the second parameter arg2. This allows enc_worker_hook() to avoid using cpi->mt_info.num_workers, which is really the size of the cpi->mt_info.workers array rather than the current value of g_threads. Remove the saving and restoring of mt_info->num_workers around the av1_encode_tiles_mt(cpi) call in encode_frame_internal(). This workaround is no longer necessary. A follow-up to commit 532ba44. Bug: 558463888, 559075253, 559225640 Change-Id: Idd5f9bef1e84b2e893699e997c307fe1fd1556c3
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 50f7fb6..da81788 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -2455,10 +2455,7 @@ const int num_workers = AOMMIN(mt_info->num_mod_workers[MOD_ENC], cm->tiles.cols * cm->tiles.rows); if (num_workers > 1) { - const int saved_num_workers = mt_info->num_workers; - mt_info->num_workers = num_workers; av1_encode_tiles_mt(cpi); - mt_info->num_workers = saved_num_workers; } else { // Preallocate the pc_tree for realtime coding to reduce the cost of // memory allocation.
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c index 22d7de7..262a671 100644 --- a/av1/encoder/ethread.c +++ b/av1/encoder/ethread.c
@@ -750,8 +750,9 @@ return 1; } -static int enc_worker_hook(void *arg1, void *unused) { +static int enc_worker_hook(void *arg1, void *arg2) { EncWorkerData *const thread_data = (EncWorkerData *)arg1; + const int num_workers = (int)(intptr_t)arg2; AV1_COMP *const cpi = thread_data->cpi; MACROBLOCKD *const xd = &thread_data->td->mb.e_mbd; struct aom_internal_error_info *const error_info = &thread_data->error_info; @@ -760,8 +761,6 @@ const int tile_rows = cm->tiles.rows; int t; - (void)unused; - xd->error_info = error_info; // The jmp_buf is valid only for the duration of the function that calls @@ -784,8 +783,7 @@ thread_data->td->pc_root = NULL; } - for (t = thread_data->start; t < tile_rows * tile_cols; - t += cpi->mt_info.num_workers) { + for (t = thread_data->start; t < tile_rows * tile_cols; t += num_workers) { int tile_row = t / tile_cols; int tile_col = t % tile_cols; @@ -1588,7 +1586,7 @@ worker->hook = hook; worker->data1 = thread_data; - worker->data2 = NULL; + worker->data2 = (void *)(intptr_t)num_workers; thread_data->thread_id = i; // Set the starting tile for each thread.