Commit 27713d93 authored by Thomas Davies's avatar Thomas Davies

EC_ADAPT: do faster adaptation initially.

Symbol count is maintained in the position after the
last CDF value.

Change-Id: I1882e48bfb1404ea7b83ef410298484939601796
parent 0f11c78d
......@@ -205,6 +205,10 @@ int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs,
for (i = 1; i < nsymbs; i++) {
cdf[i] = cdf[i - 1] + cdf[i];
}
// Store symbol count at the end of the CDF
#if CONFIG_EC_ADAPT
cdf[nsymbs] = 0;
#endif
return nsymbs;
}
......
......@@ -138,7 +138,7 @@ DECLARE_ALIGNED(16, extern const uint8_t, aom_norm[256]);
#if CONFIG_EC_ADAPT
static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
const int rate = 4 + get_msb(nsymbs);
const int rate = 4 + (cdf[nsymbs] > 31) + get_msb(nsymbs);
const int rate2 = 12 - rate;
int i, tmp;
int diff;
......@@ -162,6 +162,7 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
cdf[i] += diff;
}
#endif
cdf[nsymbs]++;
}
#endif
......
......@@ -207,13 +207,13 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full);
#if CONFIG_EC_MULTISYMBOL
typedef aom_cdf_prob coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_TOKENS];
[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
typedef aom_prob av1_blockz_probs_model[REF_TYPES][BLOCKZ_CONTEXTS];
typedef unsigned int av1_blockz_count_model[REF_TYPES][BLOCKZ_CONTEXTS][2];
extern const aom_cdf_prob av1_pareto8_token_probs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 2];
extern const aom_cdf_prob av1_pareto8_tail_cdfs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 3];
extern const aom_cdf_prob av1_pareto8_tail_probs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 3];
struct frame_contexts;
void av1_coef_pareto_cdfs(struct frame_contexts *fc);
#endif // CONFIG_EC_MULTISYMBOL
......
......@@ -17,7 +17,8 @@
#include "av1/common/seg_common.h"
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES]
[INTRA_MODES + CONFIG_EC_ADAPT];
#endif
#if CONFIG_ALT_INTRA
......
......@@ -231,19 +231,22 @@ typedef struct frame_contexts {
aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][INTRA_MODES];
aom_cdf_prob uv_mode_cdf[INTRA_MODES][INTRA_MODES];
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][INTRA_MODES + CONFIG_EC_ADAPT];
aom_cdf_prob uv_mode_cdf[INTRA_MODES][INTRA_MODES + CONFIG_EC_ADAPT];
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS]
[PARTITION_TYPES + CONFIG_EC_ADAPT];
aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
aom_cdf_prob inter_mode_cdf[INTER_MODE_CONTEXTS][INTER_MODES];
[SWITCHABLE_FILTERS + CONFIG_EC_ADAPT];
aom_cdf_prob inter_mode_cdf[INTER_MODE_CONTEXTS]
[INTER_MODES + CONFIG_EC_ADAPT];
/* Keep track of kf_y_cdf here, as this makes handling
multiple copies for adaptation in tiles easier */
aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES]
[INTRA_MODES + CONFIG_EC_ADAPT];
#if !CONFIG_EXT_TX
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES]
[TX_TYPES + CONFIG_EC_ADAPT];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES + CONFIG_EC_ADAPT];
#endif
#endif
#if CONFIG_DELTA_Q
......@@ -372,7 +375,8 @@ extern const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
[INTRA_MODES - 1];
#if CONFIG_EC_MULTISYMBOL
// CDF version of 'av1_kf_y_mode_prob'.
extern aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
extern aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES]
[INTRA_MODES + CONFIG_EC_ADAPT];
#endif
#if CONFIG_PALETTE
extern const aom_prob av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
......
......@@ -85,15 +85,15 @@ typedef struct {
aom_prob sign;
aom_prob classes[MV_CLASSES - 1];
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob class_cdf[MV_CLASSES];
aom_cdf_prob class_cdf[MV_CLASSES + CONFIG_EC_ADAPT];
#endif
aom_prob class0[CLASS0_SIZE - 1];
aom_prob bits[MV_OFFSET_BITS];
aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1];
aom_prob fp[MV_FP_SIZE - 1];
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob class0_fp_cdf[CLASS0_SIZE][MV_FP_SIZE];
aom_cdf_prob fp_cdf[MV_FP_SIZE];
aom_cdf_prob class0_fp_cdf[CLASS0_SIZE][MV_FP_SIZE + CONFIG_EC_ADAPT];
aom_cdf_prob fp_cdf[MV_FP_SIZE + CONFIG_EC_ADAPT];
#endif
aom_prob class0_hp;
aom_prob hp;
......@@ -102,7 +102,7 @@ typedef struct {
typedef struct {
aom_prob joints[MV_JOINTS - 1];
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob joint_cdf[MV_JOINTS];
aom_cdf_prob joint_cdf[MV_JOINTS + CONFIG_EC_ADAPT];
#endif
nmv_component comps[2];
} nmv_context;
......
......@@ -82,12 +82,14 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
int band, c = 0;
const int tx_size_ctx = txsize_sqr_map[tx_size];
#if CONFIG_NEW_TOKENSET
aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(
*coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_head_cdfs[tx_size_ctx][type][ref];
aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(
*coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_tail_cdfs[tx_size_ctx][type][ref];
aom_cdf_prob(*cdf_head)[ENTROPY_TOKENS];
aom_cdf_prob(*cdf_tail)[ENTROPY_TOKENS];
aom_cdf_prob(*cdf_head)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
aom_cdf_prob(*cdf_tail)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
int val = 0;
unsigned int *blockz_count;
#else
......@@ -95,13 +97,13 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
ec_ctx->coef_probs[tx_size_ctx][type][ref];
const aom_prob *prob;
#if CONFIG_EC_ADAPT
aom_cdf_prob(*coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(*coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_cdfs[tx_size][type][ref];
aom_cdf_prob(*cdf)[ENTROPY_TOKENS];
aom_cdf_prob(*cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
#elif CONFIG_EC_MULTISYMBOL
aom_cdf_prob(*coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(*coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_cdfs[tx_size_ctx][type][ref];
aom_cdf_prob(*cdf)[ENTROPY_TOKENS];
aom_cdf_prob(*cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
#endif // CONFIG_EC_ADAPT
#endif // CONFIG_NEW_TOKENSET
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] = NULL;
......
......@@ -361,10 +361,10 @@ static void set_entropy_context_b(int plane, int block, int blk_row,
}
#if CONFIG_NEW_TOKENSET
static INLINE void add_token(TOKENEXTRA **t,
aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS],
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS],
int is_eob, int32_t extra, uint8_t token) {
static INLINE void add_token(
TOKENEXTRA **t, aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT],
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT], int is_eob,
int32_t extra, uint8_t token) {
(*t)->token = token;
(*t)->extra = extra;
(*t)->tail_cdf = tail_cdf;
......@@ -374,12 +374,12 @@ static INLINE void add_token(TOKENEXTRA **t,
}
#else
static INLINE void add_token(TOKENEXTRA **t, const aom_prob *context_tree,
static INLINE void add_token(
TOKENEXTRA **t, const aom_prob *context_tree,
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS],
aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT],
#endif // CONFIG_EC_MULTISYMBOL
int32_t extra, uint8_t token,
uint8_t skip_eob_node, unsigned int *counts) {
int32_t extra, uint8_t token, uint8_t skip_eob_node, unsigned int *counts) {
(*t)->token = token;
(*t)->extra = extra;
(*t)->context_tree = context_tree;
......@@ -489,16 +489,19 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
FRAME_CONTEXT *ec_ctx = cpi->common.fc;
#endif
#if CONFIG_NEW_TOKENSET
aom_cdf_prob(*const coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(
*const coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_head_cdfs[tx_size][type][ref];
aom_cdf_prob(*const coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(
*const coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_tail_cdfs[tx_size][type][ref];
unsigned int(*const blockz_count)[2] =
td->counts->blockz_count[txsize_sqr_map[tx_size]][type][ref];
int is_eob;
#else
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob(*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
aom_cdf_prob(
*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS + CONFIG_EC_ADAPT] =
ec_ctx->coef_cdfs[tx_size][type][ref];
#endif
int skip_eob = 0;
......
......@@ -36,11 +36,11 @@ typedef struct {
typedef struct {
#if CONFIG_NEW_TOKENSET
aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS];
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS];
aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
int is_eob;
#elif CONFIG_EC_MULTISYMBOL
aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS];
aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS + CONFIG_EC_ADAPT];
#endif
const aom_prob *context_tree;
EXTRABIT extra;
......
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