Add tpl transform stats collection under a macro
Added the functions av1_record_tpl_txfm_block(),
av1_tpl_txfm_stats_update_abs_coeff_mean(),
av1_tpl_store_txfm_stats() and
av1_accumulate_tpl_txfm_stats() under the macro
CONFIG_BITRATE_ACCURACY.
Instruction Count
cpu Reduction(%)
5 0.211
6 0.297
Change-Id: I9f1bccd20d05682d16649136105ce813c2c3bbab
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index fb17b80..5ef8ea6 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -2011,6 +2011,7 @@
}
}
+#if CONFIG_BITRATE_ACCURACY
// Accumulate transform stats after tpl.
static void tpl_accumulate_txfm_stats(ThreadData *main_td,
const MultiThreadInfo *mt_info,
@@ -2026,6 +2027,7 @@
}
}
}
+#endif // CONFIG_BITRATE_ACCURACY
// Implements multi-threading for tpl.
void av1_mc_flow_dispenser_mt(AV1_COMP *cpi) {
@@ -2051,7 +2053,9 @@
prepare_tpl_workers(cpi, tpl_worker_hook, num_workers);
launch_workers(&cpi->mt_info, num_workers);
sync_enc_workers(&cpi->mt_info, cm, num_workers);
+#if CONFIG_BITRATE_ACCURACY
tpl_accumulate_txfm_stats(&cpi->td, &cpi->mt_info, num_workers);
+#endif // CONFIG_BITRATE_ACCURACY
}
// Deallocate memory for temporal filter multi-thread synchronization.
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 436ede6..38877f7 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -58,6 +58,7 @@
sizeof(tpl_txfm_stats->abs_coeff_mean[0]) * tpl_txfm_stats->coeff_num);
}
+#if CONFIG_BITRATE_ACCURACY
void av1_accumulate_tpl_txfm_stats(const TplTxfmStats *sub_stats,
TplTxfmStats *accumulated_stats) {
accumulated_stats->txfm_block_count += sub_stats->txfm_block_count;
@@ -94,6 +95,7 @@
const int frame_index) {
tpl_data->txfm_stats_list[frame_index] = *tpl_txfm_stats;
}
+#endif // CONFIG_BITRATE_ACCURACY
static AOM_INLINE void get_quantize_error(const MACROBLOCK *x, int plane,
const tran_low_t *coeff,
@@ -352,6 +354,8 @@
*recon_error = 1;
*pred_error = 1;
+ (void)tpl_txfm_stats;
+
MACROBLOCKD *xd = &x->e_mbd;
int is_compound = (best_mode == NEW_NEWMV);
int num_planes = use_y_only_rate_distortion ? 1 : MAX_MB_PLANE;
@@ -433,10 +437,12 @@
block_size_high[bsize_plane], max_txsize_rect_lookup[bsize_plane],
&this_rate, &this_recon_error, &sse);
+#if CONFIG_BITRATE_ACCURACY
if (plane == 0 && tpl_txfm_stats) {
// We only collect Y plane's transform coefficient
av1_record_tpl_txfm_block(tpl_txfm_stats, coeff);
}
+#endif // CONFIG_BITRATE_ACCURACY
*recon_error += this_recon_error;
*pred_error += sse;
@@ -1780,8 +1786,10 @@
} else {
mc_flow_dispenser(cpi);
}
+#if CONFIG_BITRATE_ACCURACY
av1_tpl_txfm_stats_update_abs_coeff_mean(&cpi->td.tpl_txfm_stats);
av1_tpl_store_txfm_stats(tpl_data, &cpi->td.tpl_txfm_stats, frame_idx);
+#endif // CONFIG_BITRATE_ACCURACY
#if CONFIG_RATECTRL_LOG && CONFIG_THREE_PASS && CONFIG_BITRATE_ACCURACY
if (cpi->oxcf.pass == AOM_RC_THIRD_PASS) {
int frame_coding_idx =
diff --git a/av1/encoder/tpl_model.h b/av1/encoder/tpl_model.h
index 71cc320..36c3ae0 100644
--- a/av1/encoder/tpl_model.h
+++ b/av1/encoder/tpl_model.h
@@ -485,6 +485,7 @@
*/
void av1_init_tpl_txfm_stats(TplTxfmStats *tpl_txfm_stats);
+#if CONFIG_BITRATE_ACCURACY
/*
*!\brief Accumulate TplTxfmStats
*
@@ -516,6 +517,7 @@
* \param[in] txfm_stats A structure for storing transform stats
*/
void av1_tpl_txfm_stats_update_abs_coeff_mean(TplTxfmStats *txfm_stats);
+#endif // CONFIG_BITRATE_ACCURACY
/*!\brief Estimate coefficient entropy using Laplace dsitribution
*
diff --git a/test/tpl_model_test.cc b/test/tpl_model_test.cc
index 674f202..3d76f86 100644
--- a/test/tpl_model_test.cc
+++ b/test/tpl_model_test.cc
@@ -202,6 +202,7 @@
}
}
+#if CONFIG_BITRATE_ACCURACY
TEST(TplModelTest, TxfmStatsAccumulateTest) {
TplTxfmStats sub_stats;
av1_init_tpl_txfm_stats(&sub_stats);
@@ -248,6 +249,7 @@
EXPECT_DOUBLE_EQ(stats2.abs_coeff_sum[i], 2 * stats1.abs_coeff_sum[i]);
}
}
+#endif // CONFIG_BITRATE_ACCURACY
TEST(TplModelTest, ComputeMVDifferenceTest) {
TplDepFrame tpl_frame_small;