Add dummy sync_read and sync_write for enc row-mt

Dummy av1_row_mt_sync_read_dummy and av1_row_mt_sync_write_dummy
function are added to facilitate row based multi-threading of enc.
Subsequent patches will add sync_read and sync_write for enc row mt.

Change-Id: I104ec4d0ce8258d12baf09cbfbb833378d8c2cff
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 0dca5f3..2d87eb7 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4492,6 +4492,8 @@
   SPEED_FEATURES *const sf = &cpi->sf;
   const int leaf_nodes = 256;
   const int sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, tile_data->tile_info);
+  int sb_row =
+      (mi_row - tile_info->mi_row_start) >> cm->seq_params.mib_size_log2;
 
   // Initialize the left context for the new SB row
   av1_zero_left_context(xd);
@@ -4506,10 +4508,13 @@
 
   PC_TREE *const pc_root =
       td->pc_root[cm->seq_params.mib_size_log2 - MIN_MIB_SIZE_LOG2];
+
   // Code each SB in the row
   for (int mi_col = tile_info->mi_col_start, sb_col_in_tile = 0;
        mi_col < tile_info->mi_col_end;
        mi_col += cm->seq_params.mib_size, sb_col_in_tile++) {
+    (*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, sb_row,
+                                   sb_col_in_tile);
     if ((cpi->row_mt == 1) && (tile_info->mi_col_start == mi_col) &&
         (tile_info->mi_row_start != mi_row)) {
       // restore frame context of 1st column sb
@@ -4745,6 +4750,8 @@
       if (update_context)
         memcpy(x->backup_tile_ctx, xd->tile_ctx, sizeof(*xd->tile_ctx));
     }
+    (*(cpi->row_mt_sync_write_ptr))(&tile_data->row_mt_sync, sb_row,
+                                    sb_col_in_tile, sb_cols_in_tile);
   }
 }
 
@@ -5543,6 +5550,8 @@
     }
 #endif
 
+    cpi->row_mt_sync_read_ptr = av1_row_mt_sync_read_dummy;
+    cpi->row_mt_sync_write_ptr = av1_row_mt_sync_write_dummy;
     if (cpi->row_mt && (cpi->oxcf.max_threads > 1)) {
       av1_encode_tiles_row_mt(cpi);
     } else {
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 467a3d2..65e2ab6 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -470,6 +470,18 @@
 } InterModesInfo;
 #endif
 
+// Encoder row synchronization
+typedef struct AV1RowMTSyncData {
+#if CONFIG_MULTITHREAD
+  pthread_mutex_t *mutex_;
+  pthread_cond_t *cond_;
+#endif
+  // Allocate memory to store the sb/mb block index in each row.
+  int *cur_col;
+  int sync_range;
+  int rows;
+} AV1RowMTSync;
+
 // TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
 typedef struct TileDataEnc {
   TileInfo tile_info;
@@ -484,6 +496,7 @@
 #if CONFIG_COLLECT_INTER_MODE_RD_STATS
   InterModeRdModel inter_mode_rd_models[BLOCK_SIZES_ALL];
 #endif
+  AV1RowMTSync row_mt_sync;
 } TileDataEnc;
 
 typedef struct {
@@ -799,6 +812,8 @@
   // Set as 1 for monochrome and 3 for other color formats
   int default_interp_skip_flags;
   int preserve_arf_as_gld;
+  void (*row_mt_sync_read_ptr)(AV1RowMTSync *const, int, int);
+  void (*row_mt_sync_write_ptr)(AV1RowMTSync *const, int, int, const int);
 } AV1_COMP;
 
 // Must not be called more than once.
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 635abd9..5837451 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -27,6 +27,23 @@
   td->rd_counts.skip_mode_used_flag |= td_t->rd_counts.skip_mode_used_flag;
 }
 
+void av1_row_mt_sync_read_dummy(struct AV1RowMTSyncData *const row_mt_sync,
+                                int r, int c) {
+  (void)row_mt_sync;
+  (void)r;
+  (void)c;
+  return;
+}
+
+void av1_row_mt_sync_write_dummy(struct AV1RowMTSyncData *const row_mt_sync,
+                                 int r, int c, const int cols) {
+  (void)row_mt_sync;
+  (void)r;
+  (void)c;
+  (void)cols;
+  return;
+}
+
 static int enc_row_mt_worker_hook(void *arg1, void *unused) {
   EncWorkerData *const thread_data = (EncWorkerData *)arg1;
   AV1_COMP *const cpi = thread_data->cpi;
diff --git a/av1/encoder/ethread.h b/av1/encoder/ethread.h
index a2323ff..36bf5e1 100644
--- a/av1/encoder/ethread.h
+++ b/av1/encoder/ethread.h
@@ -18,6 +18,7 @@
 
 struct AV1_COMP;
 struct ThreadData;
+struct AV1RowMTSyncData;
 
 typedef struct EncWorkerData {
   struct AV1_COMP *cpi;
@@ -25,6 +26,11 @@
   int start;
 } EncWorkerData;
 
+void av1_row_mt_sync_read_dummy(struct AV1RowMTSyncData *const row_mt_sync,
+                                int r, int c);
+void av1_row_mt_sync_write_dummy(struct AV1RowMTSyncData *const row_mt_sync,
+                                 int r, int c, const int cols);
+
 void av1_encode_tiles_mt(struct AV1_COMP *cpi);
 void av1_encode_tiles_row_mt(struct AV1_COMP *cpi);