Changes to facilitate hook function for enc row-mt

Dummy functions are added to facilitate row based multi-threading
of encoder. These encoding and worker hook functions are same as
tile based multi-threading of encoder.
Subsequent patches will enable row-mt for encoder.

Change-Id: I142f1a37c76f3a6f5b03c2704097a2c38b292db4
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 0db78e2..0dca5f3 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -5544,7 +5544,7 @@
 #endif
 
     if (cpi->row_mt && (cpi->oxcf.max_threads > 1)) {
-      av1_encode_tiles_mt(cpi);
+      av1_encode_tiles_row_mt(cpi);
     } else {
       cpi->row_mt = 0;
       if (AOMMIN(cpi->oxcf.max_threads, cm->tile_cols * cm->tile_rows) > 1)
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 7c0e9cc..635abd9 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -27,6 +27,32 @@
   td->rd_counts.skip_mode_used_flag |= td_t->rd_counts.skip_mode_used_flag;
 }
 
+static int enc_row_mt_worker_hook(void *arg1, void *unused) {
+  EncWorkerData *const thread_data = (EncWorkerData *)arg1;
+  AV1_COMP *const cpi = thread_data->cpi;
+  const AV1_COMMON *const cm = &cpi->common;
+  const int tile_cols = cm->tile_cols;
+  const int tile_rows = cm->tile_rows;
+  int t;
+
+  (void)unused;
+
+  for (t = thread_data->start; t < tile_rows * tile_cols;
+       t += cpi->num_workers) {
+    int tile_row = t / tile_cols;
+    int tile_col = t % tile_cols;
+
+    TileDataEnc *const this_tile =
+        &cpi->tile_data[tile_row * cm->tile_cols + tile_col];
+    thread_data->td->tctx = &this_tile->tctx;
+    thread_data->td->mb.e_mbd.tile_ctx = thread_data->td->tctx;
+    thread_data->td->mb.backup_tile_ctx = &this_tile->backup_tctx;
+    av1_encode_tile(cpi, thread_data->td, tile_row, tile_col);
+  }
+
+  return 1;
+}
+
 static int enc_worker_hook(void *arg1, void *unused) {
   EncWorkerData *const thread_data = (EncWorkerData *)arg1;
   AV1_COMP *const cpi = thread_data->cpi;
@@ -274,3 +300,25 @@
 
   for (unsigned int i = 0; i < n_counts; i++) acc[i] += cnt[i];
 }
+
+void av1_encode_tiles_row_mt(AV1_COMP *cpi) {
+  AV1_COMMON *const cm = &cpi->common;
+  const int tile_cols = cm->tile_cols;
+  const int tile_rows = cm->tile_rows;
+  int num_workers = AOMMIN(cpi->oxcf.max_threads, tile_cols * tile_rows);
+
+  if (cpi->tile_data == NULL || cpi->allocated_tiles < tile_cols * tile_rows)
+    av1_alloc_tile_data(cpi);
+
+  av1_init_tile_data(cpi);
+  // Only run once to create threads and allocate thread data.
+  if (cpi->num_workers == 0) {
+    create_enc_workers(cpi, num_workers);
+  } else {
+    num_workers = AOMMIN(num_workers, cpi->num_workers);
+  }
+  prepare_enc_workers(cpi, enc_row_mt_worker_hook, num_workers);
+  launch_enc_workers(cpi, num_workers);
+  sync_enc_workers(cpi, num_workers);
+  accumulate_counters_enc_workers(cpi, num_workers);
+}
diff --git a/av1/encoder/ethread.h b/av1/encoder/ethread.h
index 5de4b48..a2323ff 100644
--- a/av1/encoder/ethread.h
+++ b/av1/encoder/ethread.h
@@ -26,6 +26,7 @@
 } EncWorkerData;
 
 void av1_encode_tiles_mt(struct AV1_COMP *cpi);
+void av1_encode_tiles_row_mt(struct AV1_COMP *cpi);
 
 void av1_accumulate_frame_counts(struct FRAME_COUNTS *acc_counts,
                                  const struct FRAME_COUNTS *counts);