Make adaptive scan order support multi-threading

Count the non-zero appearance per tile and update per frame. This
resolves an enc/dec mismatch in multi-threading coding.

BUG=aomedia:1073

Change-Id: I474f05913e6c3f75ca3fa1057bd4809ef51af164
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index bf35d93..7edda58 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -546,6 +546,11 @@
           w, abs(tcoeff[scan[c]]) - COEFF_BASE_RANGE - 1 - NUM_BASE_LEVELS);
     }
   }
+
+#if CONFIG_ADAPT_SCAN
+  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
+  av1_update_scan_count_facade(cm, xd, mi_row, tx_size, tx_type, tcoeff, eob);
+#endif
 }
 
 void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
@@ -2403,8 +2408,8 @@
   // because av1_update_scan_count_facade() only cares if coefficients are zero
   // or not.
   const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-  av1_update_scan_count_facade((AV1_COMMON *)cm, mi_row, td->counts, tx_size,
-                               tx_type, qcoeff, eob);
+  av1_update_scan_count_facade((AV1_COMMON *)cm, xd, mi_row, tx_size, tx_type,
+                               qcoeff, eob);
 #endif
 }