diff --git a/av1/common/entropy.c b/av1/common/entropy.c index 6ed3d94a0..fc87eb1db 100644 --- a/av1/common/entropy.c +++ b/av1/common/entropy.c @@ -4012,18 +4012,6 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { TX_TYPE tx_type; #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) { update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */ count_sat = COEF_COUNT_SAT_AFTER_KEY; @@ -4031,13 +4019,16 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { update_factor = COEF_MAX_UPDATE_FACTOR; count_sat = COEF_COUNT_SAT; } +#if CONFIG_ENTROPY + if (cm->partial_prob_update == 1) update_factor = COEF_MAX_UPDATE_FACTOR; #endif // CONFIG_ENTROPY + for (tx_size = 0; tx_size < TX_SIZES; tx_size++) adapt_coef_probs(cm, tx_size, count_sat, update_factor); #if CONFIG_ENTROPY if (cm->partial_prob_update == 0) -#endif +#endif // CONFIG_ENTROPY { #if CONFIG_ADAPT_SCAN for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) { @@ -4045,13 +4036,13 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) { if (tx_size >= TX_SIZES) continue; #else 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) { av1_update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE_16); av1_update_scan_order_facade(cm, tx_size, tx_type); } } -#endif +#endif // CONFIG_ADAPT_SCAN } } diff --git a/av1/common/entropy.h b/av1/common/entropy.h index 91e7b2561..08415c71a 100644 --- a/av1/common/entropy.h +++ b/av1/common/entropy.h @@ -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); } -#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_MAX_UPDATE_FACTOR 112 #define COEF_COUNT_SAT_AFTER_KEY 24 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128 -#endif // CONFIG_ENTROPY - #if CONFIG_ADAPT_SCAN #define ADAPT_SCAN_UPDATE_RATE_16 (1 << 13) #endif @@ -343,25 +331,12 @@ static INLINE aom_prob av1_merge_probs(aom_prob pre_prob, const unsigned int ct[2], unsigned int count_sat, 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); -#endif // CONFIG_ENTROPY } static INLINE aom_prob av1_mode_mv_merge_probs(aom_prob pre_prob, 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); -#endif // CONFIG_ENTROPY } #ifdef __cplusplus diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 250fa7a5b..ae01d9a88 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -3500,10 +3500,9 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data, #if CONFIG_ENTROPY if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { - if ((mi_row + MI_SIZE) % - (MI_SIZE * - AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == - 0 && + const int mi_rows_per_update = + MI_SIZE * AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1); + if ((mi_row + MI_SIZE) % mi_rows_per_update == 0 && mi_row + MI_SIZE < cm->mi_rows && cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) { av1_partial_adapt_probs(cm, mi_row, mi_col); diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 3fde419f1..6264d4c04 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c @@ -4641,10 +4641,9 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td, #if CONFIG_ENTROPY if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { - if ((mi_row + MI_SIZE) % - (MI_SIZE * - AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == - 0 && + const int mi_rows_per_update = + MI_SIZE * AOMMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1); + if ((mi_row + MI_SIZE) % mi_rows_per_update == 0 && mi_row + MI_SIZE < cm->mi_rows && cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) { TX_SIZE t; diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 29ac811d0..2b51b4064 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c @@ -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; } } -#endif // CONFIG_ENTROPY -#if CONFIG_ENTROPY cm->do_subframe_update = cm->tile_cols == 1 && cm->tile_rows == 1; if (loop_count == 0 || frame_is_intra_only(cm) || cm->error_resilient_mode) { diff --git a/av1/encoder/subexp.c b/av1/encoder/subexp.c index 916a94734..c40ce3745 100644 --- a/av1/encoder/subexp.c +++ b/av1/encoder/subexp.c @@ -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[1] += ct[i][1]; if (i < n) - p = av1_merge_probs(p0, total_ct, COEF_COUNT_SAT_BITS, - COEF_MAX_UPDATE_FACTOR_BITS); + p = av1_merge_probs(p0, total_ct, COEF_COUNT_SAT, COEF_MAX_UPDATE_FACTOR); } return cost; }