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/encoder.c b/av1/encoder/encoder.c
index 9c341a4..094b78d 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -5747,7 +5747,7 @@
av1_average_tile_loopfilter_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
num_bwd_ctxs);
#if CONFIG_ADAPT_SCAN
- av1_adapt_scan_order(cm);
+ av1_adapt_scan_order(cm, tile_ctxs, num_bwd_ctxs);
#endif // CONFIG_ADAPT_SCAN
}
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
}
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 6ff425d..7d2f6e5 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -479,8 +479,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, c);
+ av1_update_scan_count_facade((AV1_COMMON *)cm, xd, mi_row, tx_size, tx_type,
+ qcoeff, c);
#endif
av1_set_contexts(xd, pd, plane, tx_size, c > 0, blk_col, blk_row);