intrabc: fix multithread encoding data race

Change-Id: I44ad31b395c142ef2a8efa7ddcef0acf692776dd
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 2028458..3550a96 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3446,10 +3446,6 @@
     encode_rd_sb_row(cpi, td, this_tile, mi_row, &tok);
   }
 
-#if CONFIG_INTRABC
-  cpi->intrabc_used |= td->intrabc_used_this_tile;
-#endif  // CONFIG_INTRABC
-
   cpi->tok_count[tile_row][tile_col] =
       (unsigned int)(tok - cpi->tile_tok[tile_row][tile_col]);
   assert(cpi->tok_count[tile_row][tile_col] <=
@@ -3463,9 +3459,14 @@
 
   av1_init_tile_data(cpi);
 
-  for (tile_row = 0; tile_row < cm->tile_rows; ++tile_row)
-    for (tile_col = 0; tile_col < cm->tile_cols; ++tile_col)
+  for (tile_row = 0; tile_row < cm->tile_rows; ++tile_row) {
+    for (tile_col = 0; tile_col < cm->tile_cols; ++tile_col) {
       av1_encode_tile(cpi, &cpi->td, tile_row, tile_col);
+#if CONFIG_INTRABC
+      cpi->intrabc_used |= cpi->td.intrabc_used_this_tile;
+#endif  // CONFIG_INTRABC
+    }
+  }
 }
 
 #if CONFIG_FP_MB_STATS
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 69781b7..1f2a4b0 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -179,7 +179,9 @@
   for (i = 0; i < num_workers; i++) {
     AVxWorker *const worker = &cpi->workers[i];
     EncWorkerData *const thread_data = (EncWorkerData *)worker->data1;
-
+#if CONFIG_INTRABC
+    cpi->intrabc_used |= thread_data->td->intrabc_used_this_tile;
+#endif  // CONFIG_INTRABC
     // Accumulate counters.
     if (i < cpi->num_workers - 1) {
       av1_accumulate_frame_counts(&cm->counts, thread_data->td->counts);