enc_worker_hook should return 1 on success.
enc_worker_hook should return 1, not 0, on success. Since
av1_encode_tiles_mt() ignores the return value of enc_worker_hook()
(because it ignores the return value of winterface->sync()), the return
value doesn't really matter. But it is better to return the correct
value.
Clean up the code in av1_encode_tiles_mt() that sets up worker->data1
for enc_worker_hook().
Clarify the comments that document the return value of AVxWorkerHook and
the had_error member of AVxWorker.
BUG=aomedia:2010
Change-Id: I635141fb2b1df05ef56a62bec991e0cac970cd3c
diff --git a/aom_util/aom_thread.h b/aom_util/aom_thread.h
index 3b22ac7..fdb724d 100644
--- a/aom_util/aom_thread.h
+++ b/aom_util/aom_thread.h
@@ -369,7 +369,8 @@
} AVxWorkerStatus;
// Function to be called by the worker thread. Takes two opaque pointers as
-// arguments (data1 and data2), and should return false in case of error.
+// arguments (data1 and data2). Should return true on success and return false
+// in case of error.
typedef int (*AVxWorkerHook)(void *, void *);
// Platform-dependent implementation details for the worker.
@@ -382,7 +383,7 @@
AVxWorkerHook hook; // hook to call
void *data1; // first argument passed to 'hook'
void *data2; // second argument passed to 'hook'
- int had_error; // return value of the last call to 'hook'
+ int had_error; // true if a call to 'hook' returned false
} AVxWorker;
// The interface for all thread-worker related functions. All these functions
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 404af2e..637d682 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -44,7 +44,7 @@
av1_encode_tile(cpi, thread_data->td, tile_row, tile_col);
}
- return 0;
+ return 1;
}
void av1_encode_tiles_mt(AV1_COMP *cpi) {
@@ -126,12 +126,11 @@
for (i = 0; i < num_workers; i++) {
AVxWorker *const worker = &cpi->workers[i];
- EncWorkerData *thread_data;
+ EncWorkerData *const thread_data = &cpi->tile_thr_data[i];
worker->hook = (AVxWorkerHook)enc_worker_hook;
- worker->data1 = &cpi->tile_thr_data[i];
+ worker->data1 = thread_data;
worker->data2 = NULL;
- thread_data = (EncWorkerData *)worker->data1;
// Before encoding a frame, copy the thread data from cpi.
if (thread_data->td != &cpi->td) {