add symbol to bin utility
diff --git a/aom_dsp/bitreader.h b/aom_dsp/bitreader.h
index 43bec15..42f962b 100644
--- a/aom_dsp/bitreader.h
+++ b/aom_dsp/bitreader.h
@@ -124,7 +124,8 @@
#if CONFIG_THROUGHPUT_ANALYSIS
static INLINE void aom_update_symb_counts(const aom_reader *r, int is_binary,
int is_context_coded, int n_bits,
- const aom_cdf_prob *cdf) {
+ const aom_cdf_prob *cdf,
+ int sym_len) {
#else
static INLINE void aom_update_symb_counts(const aom_reader *r, int is_binary,
int n_bits) {
@@ -135,9 +136,12 @@
#if CONFIG_THROUGHPUT_ANALYSIS
if (is_context_coded) {
r->accounting->syms.num_ctx_coded += n_bits;
+ r->accounting->syms.num_ctx_log2 += aom_ceil_log2(sym_len);
} else {
r->accounting->syms.num_bypass_coded += n_bits;
+ r->accounting->syms.num_bypass_log2 += aom_ceil_log2(sym_len);
}
+ r->accounting->syms.num_symlen_minus1 += sym_len - 1;
if (is_context_coded && cdf != NULL) {
if (cdf != r->accounting->syms.prev_context_id) {
r->accounting->syms.context_switch += 1;
@@ -192,7 +196,7 @@
if (ACCT_INFO_NAME.c_file)
aom_process_accounting(r, bit, SYMBOL_BIT, ACCT_INFO_NAME);
#if CONFIG_THROUGHPUT_ANALYSIS
- aom_update_symb_counts(r, 1, 0, 1, NULL);
+ aom_update_symb_counts(r, 1, 0, 1, NULL, 2);
#else
aom_update_symb_counts(r, 1, 1);
#endif // CONFIG_THROUGHPUT_ANALYSIS
@@ -249,7 +253,7 @@
if (ACCT_INFO_NAME.c_file)
aom_process_accounting(r, ret, SYMBOL_BIT_BYPASS, ACCT_INFO_NAME);
#if CONFIG_THROUGHPUT_ANALYSIS
- aom_update_symb_counts(r, 1, 0, 1, NULL);
+ aom_update_symb_counts(r, 1, 0, 1, NULL, 2);
#else
aom_update_symb_counts(r, 1, 1);
#endif
@@ -290,7 +294,7 @@
if (ACCT_INFO_NAME.c_file)
aom_process_accounting(r, literal, SYMBOL_LITERAL_BYPASS, ACCT_INFO_NAME);
#if CONFIG_THROUGHPUT_ANALYSIS
- aom_update_symb_counts(r, 1, 0, bits, NULL);
+ aom_update_symb_counts(r, 1, 0, bits, NULL, bits + 1);
#else
aom_update_symb_counts(r, 1, bits);
#endif
@@ -318,7 +322,7 @@
if (ACCT_INFO_NAME.c_file)
aom_process_accounting(r, ret, SYMBOL_UNARY, ACCT_INFO_NAME);
#if CONFIG_THROUGHPUT_ANALYSIS
- aom_update_symb_counts(r, 1, 0, n_bits, NULL);
+ aom_update_symb_counts(r, 1, 0, n_bits, NULL, n_bits + 1);
#else
aom_update_symb_counts(r, 1, n_bits);
#endif
@@ -376,7 +380,7 @@
if (ACCT_INFO_NAME.c_file)
aom_process_accounting(r, symb, SYMBOL_CDF, ACCT_INFO_NAME);
#if CONFIG_THROUGHPUT_ANALYSIS
- aom_update_symb_counts(r, (nsymbs == 2), 1, 1, cdf);
+ aom_update_symb_counts(r, (nsymbs == 2), 1, 1, cdf, nsymbs);
#else
aom_update_symb_counts(r, (nsymbs == 2), 1);
#endif // CONFIG_THROUGHPUT_ANALYSIS
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index ce9d6da..efd2de0 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -135,12 +135,19 @@
printf(
"avg_ctx_syms : %lld\t avg_bypass_syms : %lld\t max_ctx_syms : %lld\t "
"max_bypass_syms : %lld\t max_bits : %lld\t total_bits : %lld\t "
- "context_switches : %lld\t total_hits : %lld\n",
+ "context_switches : %lld\t total_hits : %lld\t avg_bins(sym-1) : %lld\t max_bins(sym-1) : %lld \t "
+ "avg_ctx_log2 : %lld\t avg_bypass_log2 : %lld\t max_ctx_log2 : %lld\t max_bypass_log2 : %lld\t \n",
(long long)(tot_ctx_syms / tot_frames),
(long long)(tot_bypass_syms / tot_frames), max_ctx_syms, max_bypass_syms,
(long long)(max_bits / 65536), (long long)(tot_bits / 65536),
(long long)(total_context_switch / tot_frames),
- (long long)(total_total_hits / tot_frames));
+ (long long)(total_total_hits / tot_frames),
+ (long long)(tot_symlen_minus1 / tot_frames),
+ (long long)(max_symlen_minus1),
+ (long long)(tot_ctx_log2 / tot_frames),
+ (long long)(tot_bypass_log2 / tot_frames),
+ (long long)(max_ctx_log2),
+ (long long)(max_bypass_log2));
#endif // CONFIG_THROUGHPUT_ANALYSIS
if (ctx->frame_worker != NULL) {
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index 699e26e..3afcdb9 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -1376,12 +1376,20 @@
int64_t tot_bits;
/** total ctx coded symbols. */
int64_t tot_ctx_syms;
+ /** total symbol - 1 counts for bin estimate. */
+ int64_t tot_symlen_minus1;
+ int64_t tot_bypass_log2;
+ int64_t tot_ctx_log2;
/** total bypass coded symbols. */
int64_t tot_bypass_syms;
/** peak ctx coded symbols. */
int64_t peak_ctx_syms;
/** peak bypass coded symbols. */
int64_t peak_bypass_syms;
+ /** peak symbols - 1 symbols. */
+ int64_t peak_symlen_minus1;
+ int64_t peak_bypass_log2;
+ int64_t peak_ctx_log2;
/** peak bits. */
int64_t peak_bits;
/** total number of cdf switches */
diff --git a/av1/decoder/accounting.c b/av1/decoder/accounting.c
index c24c5d5..6f98eeb 100644
--- a/av1/decoder/accounting.c
+++ b/av1/decoder/accounting.c
@@ -98,6 +98,9 @@
accounting->syms.total_hits = 0;
accounting->syms.prev_context_id = NULL;
accounting->syms.num_ctx_coded = 0;
+ accounting->syms.num_symlen_minus1 = 0;
+ accounting->syms.num_ctx_log2 = 0;
+ accounting->syms.num_bypass_log2 = 0;
accounting->context.x = -1;
accounting->context.y = -1;
accounting->last_tell_frac = 0;
diff --git a/av1/decoder/accounting.h b/av1/decoder/accounting.h
index 104ed5d..93806ce 100644
--- a/av1/decoder/accounting.h
+++ b/av1/decoder/accounting.h
@@ -102,6 +102,10 @@
int num_bypass_coded;
/** Context coded. */
int num_ctx_coded;
+ /** Estimate bins coded. */
+ int num_symlen_minus1;
+ int num_ctx_log2;
+ int num_bypass_log2;
uint16_t *prev_context_id;
int context_switch;
int total_hits;
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 1773302..e6553b8 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -114,9 +114,15 @@
#if CONFIG_THROUGHPUT_ANALYSIS
int64_t tot_ctx_syms = { 0 };
+int64_t tot_symlen_minus1 = { 0 };
+int64_t tot_bypass_log2 = { 0 };
+int64_t tot_ctx_log2 = { 0 };
int64_t tot_bypass_syms = { 0 };
int64_t max_ctx_syms = { 0 };
int64_t max_bypass_syms = { 0 };
+int64_t max_symlen_minus1 = { 0 };
+int64_t max_bypass_log2 = { 0 };
+int64_t max_ctx_log2 = { 0 };
int64_t max_bits = { 0 };
int64_t tot_bits = { 0 };
int64_t tot_frames = { 0 };
@@ -4720,17 +4726,26 @@
if (pbi->decoding_first_frame) {
pbi->common.sym_stats.frame_dec_order = 0;
pbi->common.sym_stats.tot_ctx_syms = 0;
+ pbi->common.sym_stats.tot_symlen_minus1 = 0;
+ pbi->common.sym_stats.tot_bypass_log2 = 0;
+ pbi->common.sym_stats.tot_ctx_log2 = 0;
pbi->common.sym_stats.total_total_hits = 0;
pbi->common.sym_stats.total_context_switch = 0;
pbi->common.sym_stats.tot_bypass_syms = 0;
pbi->common.sym_stats.tot_bits = 0;
pbi->common.sym_stats.peak_ctx_syms = 0;
+ pbi->common.sym_stats.peak_symlen_minus1 = 0;
+ pbi->common.sym_stats.peak_bypass_log2 = 0;
+ pbi->common.sym_stats.peak_ctx_log2 = 0;
pbi->common.sym_stats.peak_bypass_syms = 0;
pbi->common.sym_stats.peak_bits = 0;
}
Accounting accounting = pbi->accounting;
int64_t frm_ctx_syms = accounting.syms.num_ctx_coded;
int64_t frm_bypass_syms = accounting.syms.num_bypass_coded;
+ int64_t frm_symlen_minus1 = accounting.syms.num_symlen_minus1;
+ int64_t frm_bypass_log2 = accounting.syms.num_bypass_log2;
+ int64_t frm_ctx_log2 = accounting.syms.num_ctx_log2;
int64_t frm_context_switch = accounting.syms.context_switch;
int64_t frm_total_hits = accounting.syms.total_hits;
int64_t frm_bits = 0;
@@ -4741,6 +4756,9 @@
int64_t peak_ctx_syms = pbi->common.sym_stats.peak_ctx_syms;
int64_t peak_bypass_syms = pbi->common.sym_stats.peak_bypass_syms;
pbi->common.sym_stats.tot_ctx_syms += frm_ctx_syms;
+ pbi->common.sym_stats.tot_symlen_minus1 += frm_symlen_minus1;
+ pbi->common.sym_stats.tot_bypass_log2 += frm_bypass_log2;
+ pbi->common.sym_stats.tot_ctx_log2 += frm_ctx_log2;
pbi->common.sym_stats.total_context_switch += frm_context_switch;
pbi->common.sym_stats.total_total_hits += frm_total_hits;
pbi->common.sym_stats.tot_bypass_syms += frm_bypass_syms;
@@ -4751,13 +4769,22 @@
pbi->common.sym_stats.peak_ctx_syms = frm_ctx_syms;
pbi->common.sym_stats.peak_bypass_syms = frm_bypass_syms;
pbi->common.sym_stats.peak_bits = frm_bits;
+ pbi->common.sym_stats.peak_symlen_minus1 = frm_symlen_minus1;
+ pbi->common.sym_stats.peak_bypass_log2 = frm_bypass_log2;
+ pbi->common.sym_stats.peak_ctx_log2 = frm_ctx_log2;
}
tot_ctx_syms = pbi->common.sym_stats.tot_ctx_syms;
+ tot_symlen_minus1 = pbi->common.sym_stats.tot_symlen_minus1;
+ tot_ctx_log2 = pbi->common.sym_stats.tot_ctx_log2;
+ tot_bypass_log2 = pbi->common.sym_stats.tot_bypass_log2;
tot_bypass_syms = pbi->common.sym_stats.tot_bypass_syms;
tot_bits = pbi->common.sym_stats.tot_bits;
total_context_switch = pbi->common.sym_stats.total_context_switch;
total_total_hits = pbi->common.sym_stats.total_total_hits;
max_ctx_syms = pbi->common.sym_stats.peak_ctx_syms;
+ max_symlen_minus1 = pbi->common.sym_stats.peak_symlen_minus1;
+ max_bypass_log2 = pbi->common.sym_stats.peak_bypass_log2;
+ max_ctx_log2 = pbi->common.sym_stats.peak_ctx_log2;
max_bypass_syms = pbi->common.sym_stats.peak_bypass_syms;
max_bits = pbi->common.sym_stats.peak_bits;
tot_frames = pbi->common.sym_stats.frame_dec_order;
diff --git a/av1/decoder/decodeframe.h b/av1/decoder/decodeframe.h
index 9e32dfb..ca42d41 100644
--- a/av1/decoder/decodeframe.h
+++ b/av1/decoder/decodeframe.h
@@ -19,9 +19,15 @@
#if CONFIG_THROUGHPUT_ANALYSIS
extern int64_t tot_ctx_syms;
+extern int64_t tot_symlen_minus1;
+extern int64_t tot_bypass_log2;
+extern int64_t tot_ctx_log2;
extern int64_t tot_bypass_syms;
extern int64_t max_ctx_syms;
extern int64_t max_bypass_syms;
+extern int64_t max_symlen_minus1;
+extern int64_t max_bypass_log2;
+extern int64_t max_ctx_log2;
extern int64_t max_bits;
extern int64_t tot_bits;
extern int64_t tot_frames;