Add counter to count #tx_searches during encoding
Add counter to count # tx searches during encoding to help with
encoder optimation and speed-ups.
The counter is added in the CONFIG_SPEED_STATS configuration
macro which is off by default. Other similar counters may be added
within this flag subsequently.
Change-Id: I09ecd8b20045c66fe1a850cebb7b703d44ece69e
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index df0196e..7cd8590 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -263,6 +263,9 @@
int *ex_search_count_ptr;
unsigned int txb_split_count;
+#if CONFIG_SPEED_STATS
+ unsigned int tx_search_count;
+#endif // CONFIG_SPEED_STATS
// These are set to their default values at the beginning, and then adjusted
// further in the encoding process.
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 2f92da9..acc0cbd 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -6302,6 +6302,9 @@
cm->prev_mi = cm->allow_ref_frame_mvs ? cm->prev_mip : NULL;
x->txb_split_count = 0;
+#if CONFIG_SPEED_STATS
+ x->tx_search_count = 0;
+#endif // CONFIG_SPEED_STATS
av1_zero(rdc->global_motion_used);
av1_zero(cpi->gmparams_cost);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 9b3ab84..135e3f4 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2683,6 +2683,9 @@
cpi->count = 0;
cpi->bytes = 0;
+#if CONFIG_SPEED_STATS
+ cpi->tx_search_count = 0;
+#endif // CONFIG_SPEED_STATS
if (cpi->b_calculate_psnr) {
cpi->total_sq_error = 0;
@@ -3113,6 +3116,11 @@
fclose(f);
}
#endif // CONFIG_INTERNAL_STATS
+#if CONFIG_SPEED_STATS
+ if (cpi->oxcf.pass != 1) {
+ fprintf(stdout, "tx_search_count = %d\n", cpi->tx_search_count);
+ }
+#endif // CONFIG_SPEED_STATS
}
for (int frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
@@ -6984,6 +6992,12 @@
compute_internal_stats(cpi, (int)(*size));
}
#endif // CONFIG_INTERNAL_STATS
+#if CONFIG_SPEED_STATS
+ if (cpi->oxcf.pass != 1) {
+ cpi->tx_search_count += cpi->td.mb.tx_search_count;
+ cpi->td.mb.tx_search_count = 0;
+ }
+#endif // CONFIG_SPEED_STATS
aom_clear_system_state();
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index d84eec5..910b2de 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -767,6 +767,9 @@
Metrics metrics;
#endif
int b_calculate_psnr;
+#if CONFIG_SPEED_STATS
+ unsigned int tx_search_count;
+#endif // CONFIG_SPEED_STATS
int droppable;
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 943567f..ceb76c1 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -517,6 +517,9 @@
av1_accumulate_frame_counts(&cpi->counts, thread_data->td->counts);
accumulate_rd_opt(&cpi->td, thread_data->td);
cpi->td.mb.txb_split_count += thread_data->td->mb.txb_split_count;
+#if CONFIG_SPEED_STATS
+ cpi->td.mb.tx_search_count += thread_data->td->mb.tx_search_count;
+#endif // CONFIG_SPEED_STATS
}
}
}
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 9923e45..2448219 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -5835,6 +5835,9 @@
save_tx_rd_info(n4, hash, x, rd_stats, mb_rd_record);
return;
}
+#if CONFIG_SPEED_STATS
+ ++x->tx_search_count;
+#endif // CONFIG_SPEED_STATS
// Precompute residual hashes and find existing or add new RD records to
// store and reuse rate and distortion values to speed up TX size search.
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index ba4b99f..db0c9b9 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -125,6 +125,7 @@
# AV1 experiment flags.
set_aom_config_var(CONFIG_COLLECT_INTER_MODE_RD_STATS 1 NUMBER
"AV1 experiment flag.")
+set_aom_config_var(CONFIG_SPEED_STATS 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_COLLECT_RD_STATS 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_DIST_8X8 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_ENTROPY_STATS 0 NUMBER "AV1 experiment flag.")