Commit 7a645e4e authored by Deb Mukherjee's avatar Deb Mukherjee

Merging the model coef prob experiment

Merges the experiment.

Change-Id: I4eb19af6de6df6aa3a96a2e82f231d47ed9b3ae9
parent 90a7723f
......@@ -240,7 +240,6 @@ HAVE_LIST="
EXPERIMENT_LIST="
csm
implicit_segmentation
modelcoefprob
loop_dering
scatterscan
oneshotq
......
......@@ -14,12 +14,8 @@
/* Update probabilities for the nodes in the token entropy tree.
Generated file included by vp9_entropy.c */
static const vp9_prob vp9_coef_update_prob[ENTROPY_NODES] = {
252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252
static const vp9_prob vp9_coef_update_prob[UNCONSTRAINED_NODES] = {
252, 252, 252,
};
#if CONFIG_MODELCOEFPROB
#define COEF_MODEL_UPDATE_PROB 16
#endif
#endif // VP9_COMMON_VP9_COEFUPDATEPROBS_H__
This diff is collapsed.
......@@ -407,7 +407,6 @@ static const vp9_prob Pcat6[] = {
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
};
#if CONFIG_MODELCOEFPROB
const vp9_tree_index vp9_coefmodel_tree[6] = {
-DCT_EOB_MODEL_TOKEN, 2, /* 0 = EOB */
-ZERO_TOKEN, 4, /* 1 = ZERO */
......@@ -421,6 +420,8 @@ const vp9_tree_index vp9_coefmodel_tree[6] = {
// For a given beta and a given probablity of the 1-node, the alpha
// is first solved, and then the {alpha, beta} pair is used to generate
// the probabilities for the rest of the nodes.
// beta = 8
const vp9_prob vp9_modelcoefprobs_pareto8[COEFPROB_MODELS][MODEL_NODES] = {
{ 3, 86, 128, 6, 86, 23, 88, 29},
{ 9, 86, 129, 17, 88, 61, 94, 76},
......@@ -529,7 +530,6 @@ void vp9_model_to_full_probs_sb(
vp9_model_to_full_probs(model[c][p], b, r, full[c][p]);
}
}
#endif
static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28];
......@@ -766,7 +766,6 @@ void vp9_coef_tree_initialize() {
#define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
#if CONFIG_MODELCOEFPROB
void vp9_full_to_model_counts(
vp9_coeff_count_model *model_count, vp9_coeff_count *full_count) {
int i, j, k, l;
......@@ -789,32 +788,19 @@ void vp9_full_to_model_counts(
full_count[i][j][k][l][DCT_EOB_TOKEN];
}
}
#endif
static void adapt_coef_probs(
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model *dst_coef_probs,
vp9_coeff_probs_model *pre_coef_probs,
vp9_coeff_count_model *coef_counts,
#else
vp9_coeff_probs *dst_coef_probs,
vp9_coeff_probs *pre_coef_probs,
vp9_coeff_count *coef_counts,
#endif
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS],
int count_sat,
int update_factor) {
int t, i, j, k, l, count;
int factor;
#if CONFIG_MODELCOEFPROB
unsigned int branch_ct[UNCONSTRAINED_NODES][2];
vp9_prob coef_probs[UNCONSTRAINED_NODES];
int entropy_nodes_adapt = UNCONSTRAINED_NODES;
#else
unsigned int branch_ct[ENTROPY_NODES][2];
vp9_prob coef_probs[ENTROPY_NODES];
int entropy_nodes_adapt = ENTROPY_NODES;
#endif
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
......@@ -823,11 +809,7 @@ static void adapt_coef_probs(
if (l >= 3 && k == 0)
continue;
vp9_tree_probs_from_distribution(
#if CONFIG_MODELCOEFPROB
vp9_coefmodel_tree,
#else
vp9_coef_tree,
#endif
coef_probs, branch_ct,
coef_counts[i][j][k][l], 0);
branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
......
......@@ -38,10 +38,8 @@
extern const vp9_tree_index vp9_coef_tree[];
#if CONFIG_MODELCOEFPROB
#define DCT_EOB_MODEL_TOKEN 3 /* EOB Extra Bits 0+0 */
extern const vp9_tree_index vp9_coefmodel_tree[];
#endif
extern struct vp9_token vp9_coef_encodings[MAX_ENTROPY_TOKENS];
......@@ -156,7 +154,6 @@ extern int vp9_get_coef_context(const int *scan, const int *neighbors,
int nb_pad, uint8_t *token_cache, int c, int l);
const int *vp9_get_coef_neighbors_handle(const int *scan, int *pad);
#if CONFIG_MODELCOEFPROB
// 48 lists of probabilities are stored for the following ONE node probs:
// 1, (count 1)
......@@ -193,7 +190,6 @@ void vp9_model_to_full_probs_sb(
extern const vp9_prob vp9_modelcoefprobs[COEFPROB_MODELS][ENTROPY_NODES - 1];
void vp9_get_model_distribution(vp9_prob model, vp9_prob *tree_probs,
int b, int r);
#endif // CONFIG_MODELCOEFPROB
static INLINE const int* get_scan_4x4(TX_TYPE tx_type) {
switch (tx_type) {
......
......@@ -73,7 +73,6 @@ typedef struct frame_contexts {
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int partition_counts[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs_model coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs_model coef_probs_16x16[BLOCK_TYPES];
......@@ -86,20 +85,6 @@ typedef struct frame_contexts {
vp9_coeff_count_model coef_counts_8x8[BLOCK_TYPES];
vp9_coeff_count_model coef_counts_16x16[BLOCK_TYPES];
vp9_coeff_count_model coef_counts_32x32[BLOCK_TYPES];
#else
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES];
vp9_coeff_count coef_counts_32x32[BLOCK_TYPES];
#endif
unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
......
......@@ -551,18 +551,10 @@ static void init_frame(VP9D_COMP *pbi) {
}
static void read_coef_probs_common(
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model *coef_probs,
#else
vp9_coeff_probs *coef_probs,
#endif
TX_SIZE tx_size,
vp9_reader *r) {
#if CONFIG_MODELCOEFPROB
const int entropy_nodes_update = UNCONSTRAINED_NODES;
#else
const int entropy_nodes_update = ENTROPY_NODES;
#endif
int i, j, k, l, m;
......@@ -1068,10 +1060,9 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
if (vp9_read(&header_bc, 252))
pc->fc.vp9_mode_contexts[i][j] = vp9_read_prob(&header_bc);
}
#if CONFIG_MODELCOEFPROB
// Is this needed ?
if (pc->frame_type == KEY_FRAME)
vp9_default_coef_probs(pc);
#endif
update_frame_context(&pc->fc);
......
......@@ -60,7 +60,6 @@ static const vp9_prob cat6_prob[15] = {
DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
#if CONFIG_MODELCOEFPROB
#define INCREMENT_COUNT(token) \
do { \
coef_counts[type][ref][band][pt] \
......@@ -69,14 +68,6 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
token]++; \
token_cache[scan[c]] = token; \
} while (0)
#else
#define INCREMENT_COUNT(token) \
do { \
coef_counts[type][ref][band] \
[pt][token]++; \
token_cache[scan[c]] = token; \
} while (0)
#endif
#define WRITE_COEF_CONTINUE(val, token) \
{ \
......@@ -102,7 +93,6 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
FRAME_CONTEXT *const fc = &dx->common.fc;
int pt, c = 0, pad, default_eob;
int band;
#if CONFIG_MODELCOEFPROB
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES];
vp9_prob coef_probs_full[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
uint8_t load_map[COEF_BANDS][PREV_COEF_CONTEXTS] = {
......@@ -113,16 +103,9 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
};
#else
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][ENTROPY_NODES];
#endif
vp9_prob *prob;
#if CONFIG_MODELCOEFPROB
vp9_coeff_count_model *coef_counts;
#else
vp9_coeff_count *coef_counts;
#endif
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
TX_TYPE tx_type = DCT_DCT;
const int *scan, *nb;
......@@ -221,7 +204,6 @@ SKIP_START:
if (!vp9_read(r, prob[ONE_CONTEXT_NODE])) {
WRITE_COEF_CONTINUE(1, ONE_TOKEN);
}
#if CONFIG_MODELCOEFPROB
// Load full probabilities if not already loaded
if (!load_map[band][pt]) {
vp9_model_to_full_probs(coef_probs[band][pt], type, ref,
......@@ -229,7 +211,6 @@ SKIP_START:
load_map[band][pt] = 1;
}
prob = coef_probs_full[band][pt];
#endif
// LOW_VAL_CONTEXT_NODE_0_
if (!vp9_read(r, prob[LOW_VAL_CONTEXT_NODE])) {
if (!vp9_read(r, prob[TWO_CONTEXT_NODE])) {
......@@ -287,11 +268,7 @@ SKIP_START:
}
if (c < seg_eob)
#if CONFIG_MODELCOEFPROB
coef_counts[type][ref][band][pt][DCT_EOB_MODEL_TOKEN]++;
#else
coef_counts[type][ref][band][pt][DCT_EOB_TOKEN]++;
#endif
for (pt = 0; pt < (1 << txfm_size); pt++) {
A[pt] = L[pt] = c > 0;
......
......@@ -411,7 +411,6 @@ static int prob_diff_update_savings_search(const unsigned int *ct,
return bestsavings;
}
#if CONFIG_MODELCOEFPROB
static int prob_diff_update_savings_search_model(const unsigned int *ct,
const vp9_prob *oldp,
vp9_prob *bestp,
......@@ -448,7 +447,6 @@ static int prob_diff_update_savings_search_model(const unsigned int *ct,
*bestp = bestnewp;
return bestsavings;
}
#endif
static void vp9_cond_prob_update(vp9_writer *bc, vp9_prob *oldp, vp9_prob upd,
unsigned int *ct) {
......@@ -479,15 +477,12 @@ static void pack_mb_tokens(vp9_writer* const bc,
int v = a->value;
int n = a->len;
int ncount = n;
#if CONFIG_MODELCOEFPROB
vp9_prob probs[ENTROPY_NODES];
#endif
if (t == EOSB_TOKEN) {
++p;
break;
}
#if CONFIG_MODELCOEFPROB
if (t >= TWO_TOKEN) {
vp9_model_to_full_probs(p->context_tree,
p->block_type, p->ref_type, probs);
......@@ -495,9 +490,6 @@ static void pack_mb_tokens(vp9_writer* const bc,
} else {
pp = p->context_tree;
}
#else
pp = p->context_tree;
#endif
assert(pp != 0);
/* skip one or two nodes */
......@@ -1219,22 +1211,14 @@ static void update_coef_probs_common(
vp9_coeff_stats *tree_update_hist,
#endif
vp9_coeff_probs *new_frame_coef_probs,
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model *old_frame_coef_probs,
#else
vp9_coeff_probs *old_frame_coef_probs,
#endif
vp9_coeff_stats *frame_branch_ct,
TX_SIZE tx_size) {
int i, j, k, l, t;
int update[2] = {0, 0};
int savings;
#if CONFIG_MODELCOEFPROB
const int entropy_nodes_update = UNCONSTRAINED_NODES;
#else
const int entropy_nodes_update = ENTROPY_NODES;
#endif
// vp9_prob bestupd = find_coef_update_prob(cpi);
const int tstart = 0;
......@@ -1254,13 +1238,11 @@ static void update_coef_probs_common(
if (l >= 3 && k == 0)
continue;
#if CONFIG_MODELCOEFPROB
if (t == PIVOT_NODE)
s = prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j);
else
#endif
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][l][t], oldp, &newp, upd);
if (s > 0 && newp != oldp)
......@@ -1298,13 +1280,11 @@ static void update_coef_probs_common(
if (l >= 3 && k == 0)
continue;
#if CONFIG_MODELCOEFPROB
if (t == PIVOT_NODE)
s = prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j);
else
#endif
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][l][t],
*oldp, &newp, upd);
......
......@@ -2922,11 +2922,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
#endif
// transform / motion compensation build reconstruction frame
#if CONFIG_MODELCOEFPROB
if (cm->frame_type == KEY_FRAME) {
vp9_default_coef_probs(cm);
}
#endif
vp9_encode_frame(cpi);
......@@ -3175,7 +3173,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
release_scaled_references(cpi);
update_reference_frames(cpi);
#if CONFIG_MODELCOEFPROB
vp9_full_to_model_counts(cpi->common.fc.coef_counts_4x4,
cpi->coef_counts_4x4);
vp9_full_to_model_counts(cpi->common.fc.coef_counts_8x8,
......@@ -3184,12 +3181,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->coef_counts_16x16);
vp9_full_to_model_counts(cpi->common.fc.coef_counts_32x32,
cpi->coef_counts_32x32);
#else
vp9_copy(cpi->common.fc.coef_counts_4x4, cpi->coef_counts_4x4);
vp9_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8);
vp9_copy(cpi->common.fc.coef_counts_16x16, cpi->coef_counts_16x16);
vp9_copy(cpi->common.fc.coef_counts_32x32, cpi->coef_counts_32x32);
#endif
if (!cpi->common.error_resilient_mode &&
!cpi->common.frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(&cpi->common);
......
......@@ -76,17 +76,10 @@ typedef struct {
// 0 = I4X4_PRED, ZERO_MV, MV, SPLIT
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs_model coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs_model coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs_model coef_probs_32x32[BLOCK_TYPES];
#else
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES];
#endif
vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
......
......@@ -106,11 +106,7 @@ const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
};
static void fill_token_costs(vp9_coeff_count *c,
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model *p,
#else
vp9_coeff_probs *p,
#endif
TX_SIZE tx_size) {
int i, j, k, l;
......@@ -118,15 +114,10 @@ static void fill_token_costs(vp9_coeff_count *c,
for (j = 0; j < REF_TYPES; j++)
for (k = 0; k < COEF_BANDS; k++)
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
#if CONFIG_MODELCOEFPROB
vp9_prob probs[ENTROPY_NODES];
vp9_model_to_full_probs(p[i][j][k][l], i, j, probs);
vp9_cost_tokens_skip((int *)c[i][j][k][l], probs,
vp9_coef_tree);
#else
vp9_cost_tokens_skip((int *)c[i][j][k][l], p[i][j][k][l],
vp9_coef_tree);
#endif
}
}
......@@ -280,11 +271,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
TX_TYPE tx_type = DCT_DCT;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
#if CONFIG_MODELCOEFPROB
vp9_prob coef_probs[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
#else
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][ENTROPY_NODES];
#endif
int seg_eob, default_eob;
uint8_t token_cache[1024];
const uint8_t * band_translate;
......@@ -304,12 +291,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
get_tx_type_4x4(xd, block) : DCT_DCT;
above_ec = A[0] != 0;
left_ec = L[0] != 0;
#if CONFIG_MODELCOEFPROB
vp9_model_to_full_probs_sb(cm->fc.coef_probs_4x4[type][ref],
type, ref, coef_probs);
#else
coef_probs = cm->fc.coef_probs_4x4[type][ref];
#endif
seg_eob = 16;
scan = get_scan_4x4(tx_type);
band_translate = vp9_coefband_trans_4x4;
......@@ -324,12 +307,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
above_ec = (A[0] + A[1]) != 0;
left_ec = (L[0] + L[1]) != 0;
scan = get_scan_8x8(tx_type);
#if CONFIG_MODELCOEFPROB
vp9_model_to_full_probs_sb(cm->fc.coef_probs_8x8[type][ref],
type, ref, coef_probs);
#else
coef_probs = cm->fc.coef_probs_8x8[type][ref];
#endif
seg_eob = 64;
band_translate = vp9_coefband_trans_8x8plus;
break;
......@@ -341,12 +320,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
scan = get_scan_16x16(tx_type);
#if CONFIG_MODELCOEFPROB
vp9_model_to_full_probs_sb(cm->fc.coef_probs_16x16[type][ref],
type, ref, coef_probs);
#else
coef_probs = cm->fc.coef_probs_16x16[type][ref];
#endif
seg_eob = 256;
above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
......@@ -355,12 +330,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
#if CONFIG_MODELCOEFPROB
vp9_model_to_full_probs_sb(cm->fc.coef_probs_32x32[type][ref],
type, ref, coef_probs);
#else
coef_probs = cm->fc.coef_probs_32x32[type][ref];
#endif
seg_eob = 1024;
above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0;
left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0;
......
......@@ -136,11 +136,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
const int segment_id = mbmi->segment_id;
const int *scan, *nb;
vp9_coeff_count *counts;
#if CONFIG_MODELCOEFPROB
vp9_coeff_probs_model *coef_probs;
#else
vp9_coeff_probs *coef_probs;
#endif
const int ref = mbmi->ref_frame != INTRA_FRAME;
ENTROPY_CONTEXT above_ec, left_ec;
uint8_t token_cache[1024];
......@@ -228,10 +224,8 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
t->token = token;
t->context_tree = coef_probs[type][ref][band][pt];
#if CONFIG_MODELCOEFPROB
t->block_type = type;
t->ref_type = ref;
#endif
t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0);
assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0);
......
......@@ -26,10 +26,8 @@ typedef struct {
int16_t extra;
uint8_t token;
uint8_t skip_eob_node;
#if CONFIG_MODELCOEFPROB
uint8_t block_type;
uint8_t ref_type;
#endif
} TOKENEXTRA;
typedef int64_t vp9_coeff_accum[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
......
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