Commit 0161a932 authored by hui su's avatar hui su Committed by Hui Su

Cleanup for the entropy experiment

Minor performance changes
0.03% better on lowres
0.01% better on midres

Change-Id: I7a7168f3a2a4d17a03353841a416eff6edf1e241
parent 9a416f57
...@@ -4012,18 +4012,6 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { ...@@ -4012,18 +4012,6 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
TX_TYPE tx_type; TX_TYPE tx_type;
#endif #endif
#if CONFIG_ENTROPY
if (!frame_is_intra_only(cm) && cm->last_frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY_BITS; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY_BITS;
} else {
update_factor = COEF_MAX_UPDATE_FACTOR_BITS;
count_sat = COEF_COUNT_SAT_BITS;
}
if (cm->partial_prob_update == 1) {
update_factor = COEF_MAX_UPDATE_FACTOR_BITS;
}
#else
if (!frame_is_intra_only(cm) && cm->last_frame_type == KEY_FRAME) { if (!frame_is_intra_only(cm) && cm->last_frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */ update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY; count_sat = COEF_COUNT_SAT_AFTER_KEY;
...@@ -4031,13 +4019,16 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { ...@@ -4031,13 +4019,16 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
update_factor = COEF_MAX_UPDATE_FACTOR; update_factor = COEF_MAX_UPDATE_FACTOR;
count_sat = COEF_COUNT_SAT; count_sat = COEF_COUNT_SAT;
} }
#if CONFIG_ENTROPY
if (cm->partial_prob_update == 1) update_factor = COEF_MAX_UPDATE_FACTOR;
#endif // CONFIG_ENTROPY #endif // CONFIG_ENTROPY
for (tx_size = 0; tx_size < TX_SIZES; tx_size++) for (tx_size = 0; tx_size < TX_SIZES; tx_size++)
adapt_coef_probs(cm, tx_size, count_sat, update_factor); adapt_coef_probs(cm, tx_size, count_sat, update_factor);
#if CONFIG_ENTROPY #if CONFIG_ENTROPY
if (cm->partial_prob_update == 0) if (cm->partial_prob_update == 0)
#endif #endif // CONFIG_ENTROPY
{ {
#if CONFIG_ADAPT_SCAN #if CONFIG_ADAPT_SCAN
for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) { for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
...@@ -4045,13 +4036,13 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { ...@@ -4045,13 +4036,13 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
if (tx_size >= TX_SIZES) continue; if (tx_size >= TX_SIZES) continue;
#else #else
if (tx_size > TX_32X16) continue; if (tx_size > TX_32X16) continue;
#endif #endif // !(CONFIG_VAR_TX || CONFIG_RECT_TX)
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) { for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
av1_update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE_16); av1_update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE_16);
av1_update_scan_order_facade(cm, tx_size, tx_type); av1_update_scan_order_facade(cm, tx_size, tx_type);
} }
} }
#endif #endif // CONFIG_ADAPT_SCAN
} }
} }
......
...@@ -318,23 +318,11 @@ static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a, ...@@ -318,23 +318,11 @@ static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
return combine_entropy_contexts(above_ec, left_ec); return combine_entropy_contexts(above_ec, left_ec);
} }
#if CONFIG_ENTROPY
#define COEF_COUNT_SAT_BITS 5
#define COEF_MAX_UPDATE_FACTOR_BITS 7
#define COEF_COUNT_SAT_AFTER_KEY_BITS 5
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY_BITS 7
#define MODE_MV_COUNT_SAT_BITS 5
#define MODE_MV_MAX_UPDATE_FACTOR_BITS 7
#else
#define COEF_COUNT_SAT 24 #define COEF_COUNT_SAT 24
#define COEF_MAX_UPDATE_FACTOR 112 #define COEF_MAX_UPDATE_FACTOR 112
#define COEF_COUNT_SAT_AFTER_KEY 24 #define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
#endif // CONFIG_ENTROPY
#if CONFIG_ADAPT_SCAN #if CONFIG_ADAPT_SCAN
#define ADAPT_SCAN_UPDATE_RATE_16 (1 << 13) #define ADAPT_SCAN_UPDATE_RATE_16 (1 << 13)
#endif #endif
...@@ -343,25 +331,12 @@ static INLINE aom_prob av1_merge_probs(aom_prob pre_prob, ...@@ -343,25 +331,12 @@ static INLINE aom_prob av1_merge_probs(aom_prob pre_prob,
const unsigned int ct[2], const unsigned int ct[2],
unsigned int count_sat, unsigned int count_sat,
unsigned int max_update_factor) { unsigned int max_update_factor) {
#if CONFIG_ENTROPY
const aom_prob prob = get_binary_prob(ct[0], ct[1]);
const unsigned int count =
AOMMIN(ct[0] + ct[1], (unsigned int)(1 << count_sat));
const unsigned int factor = count << (max_update_factor - count_sat);
return weighted_prob(pre_prob, prob, factor);
#else
return merge_probs(pre_prob, ct, count_sat, max_update_factor); return merge_probs(pre_prob, ct, count_sat, max_update_factor);
#endif // CONFIG_ENTROPY
} }
static INLINE aom_prob av1_mode_mv_merge_probs(aom_prob pre_prob, static INLINE aom_prob av1_mode_mv_merge_probs(aom_prob pre_prob,
const unsigned int ct[2]) { const unsigned int ct[2]) {
#if CONFIG_ENTROPY
return av1_merge_probs(pre_prob, ct, MODE_MV_COUNT_SAT_BITS,
MODE_MV_MAX_UPDATE_FACTOR_BITS);
#else
return mode_mv_merge_probs(pre_prob, ct); return mode_mv_merge_probs(pre_prob, ct);
#endif // CONFIG_ENTROPY
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -3500,10 +3500,9 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data, ...@@ -3500,10 +3500,9 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
#if CONFIG_ENTROPY #if CONFIG_ENTROPY
if (cm->do_subframe_update && if (cm->do_subframe_update &&
cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
if ((mi_row + MI_SIZE) % const int mi_rows_per_update =
(MI_SIZE * MI_SIZE * AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1);
AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == if ((mi_row + MI_SIZE) % mi_rows_per_update == 0 &&
0 &&
mi_row + MI_SIZE < cm->mi_rows && mi_row + MI_SIZE < cm->mi_rows &&
cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) { cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) {
av1_partial_adapt_probs(cm, mi_row, mi_col); av1_partial_adapt_probs(cm, mi_row, mi_col);
......
...@@ -4641,10 +4641,9 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td, ...@@ -4641,10 +4641,9 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
#if CONFIG_ENTROPY #if CONFIG_ENTROPY
if (cm->do_subframe_update && if (cm->do_subframe_update &&
cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
if ((mi_row + MI_SIZE) % const int mi_rows_per_update =
(MI_SIZE * MI_SIZE * AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1);
AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == if ((mi_row + MI_SIZE) % mi_rows_per_update == 0 &&
0 &&
mi_row + MI_SIZE < cm->mi_rows && mi_row + MI_SIZE < cm->mi_rows &&
cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) { cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) {
TX_SIZE t; TX_SIZE t;
......
...@@ -4130,9 +4130,7 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size, ...@@ -4130,9 +4130,7 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
cm->frame_contexts[cm->frame_context_idx] = *cm->fc; cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
} }
} }
#endif // CONFIG_ENTROPY
#if CONFIG_ENTROPY
cm->do_subframe_update = cm->tile_cols == 1 && cm->tile_rows == 1; cm->do_subframe_update = cm->tile_cols == 1 && cm->tile_rows == 1;
if (loop_count == 0 || frame_is_intra_only(cm) || if (loop_count == 0 || frame_is_intra_only(cm) ||
cm->error_resilient_mode) { cm->error_resilient_mode) {
......
...@@ -190,8 +190,7 @@ static int get_cost(unsigned int ct[][2], aom_prob p, int n) { ...@@ -190,8 +190,7 @@ static int get_cost(unsigned int ct[][2], aom_prob p, int n) {
total_ct[0] += ct[i][0]; total_ct[0] += ct[i][0];
total_ct[1] += ct[i][1]; total_ct[1] += ct[i][1];
if (i < n) if (i < n)
p = av1_merge_probs(p0, total_ct, COEF_COUNT_SAT_BITS, p = av1_merge_probs(p0, total_ct, COEF_COUNT_SAT, COEF_MAX_UPDATE_FACTOR);
COEF_MAX_UPDATE_FACTOR_BITS);
} }
return cost; return cost;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment