Commit 377fa8af authored by Dmitry Kovalev's avatar Dmitry Kovalev

Renaming PREV_COEF_CONTEXTS to COEFF_CONTEXTS.

Also adding BAND_COEFF_CONTEXTS macro to simplify for loop logic.

Change-Id: I12a78a49cf1addf81e6b3fe2a3736ec2b79bd79e
parent da519166
......@@ -760,7 +760,7 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE tx_size,
vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[tx_size];
const vp9_coeff_probs_model *pre_coef_probs = pre_fc->coef_probs[tx_size];
vp9_coeff_count_model *coef_counts = cm->counts.coef[tx_size];
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
cm->counts.eob_branch[tx_size];
int i, j, k, l, m;
unsigned int branch_ct[UNCONSTRAINED_NODES][2];
......@@ -768,9 +768,7 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE tx_size,
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
vp9_tree_probs_from_distribution(vp9_coefmodel_tree, branch_ct,
coef_counts[i][j][k][l]);
branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
......
......@@ -82,13 +82,14 @@ extern const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS];
coefficient band (and since zigzag positions 0, 1, and 2 are in
distinct bands). */
#define PREV_COEF_CONTEXTS 6
#define COEFF_CONTEXTS 6
#define BAND_COEFF_CONTEXTS(band) ((band) == 0 ? 3 : COEFF_CONTEXTS)
// #define ENTROPY_STATS
typedef unsigned int vp9_coeff_count[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_count[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_TOKENS];
typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_NODES][2];
#define SUBEXP_PARAM 4 /* Subexponential code parameter */
......@@ -137,11 +138,10 @@ static const uint8_t *get_band_translate(TX_SIZE tx_size) {
extern const vp9_prob vp9_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES];
typedef vp9_prob vp9_coeff_probs_model[REF_TYPES][COEF_BANDS]
[PREV_COEF_CONTEXTS]
[UNCONSTRAINED_NODES];
[COEFF_CONTEXTS][UNCONSTRAINED_NODES];
typedef unsigned int vp9_coeff_count_model[REF_TYPES][COEF_BANDS]
[PREV_COEF_CONTEXTS]
[COEFF_CONTEXTS]
[UNCONSTRAINED_NODES + 1];
void vp9_model_to_full_probs(const vp9_prob *model, vp9_prob *full);
......
......@@ -66,7 +66,7 @@ typedef struct {
unsigned int partition[PARTITION_CONTEXTS][PARTITION_TYPES];
vp9_coeff_count_model coef[TX_SIZES][BLOCK_TYPES];
unsigned int eob_branch[TX_SIZES][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
[COEF_BANDS][COEFF_CONTEXTS];
unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
......
......@@ -537,13 +537,12 @@ static void read_coef_probs_common(vp9_coeff_probs_model *coef_probs,
int i, j, k, l, m;
if (vp9_read_bit(r))
for (i = 0; i < BLOCK_TYPES; i++)
for (j = 0; j < REF_TYPES; j++)
for (k = 0; k < COEF_BANDS; k++)
for (l = 0; l < PREV_COEF_CONTEXTS; l++)
if (k > 0 || l < 3)
for (m = 0; m < UNCONSTRAINED_NODES; m++)
vp9_diff_update_prob(r, &coef_probs[i][j][k][l][m]);
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l)
for (m = 0; m < UNCONSTRAINED_NODES; ++m)
vp9_diff_update_prob(r, &coef_probs[i][j][k][l][m]);
}
static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode,
......
......@@ -87,12 +87,12 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, int block,
FRAME_COUNTS *const counts = &cm->counts;
const int ref = is_inter_block(&xd->mi_8x8[0]->mbmi);
int band, c = 0;
const vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES] =
const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
const vp9_prob *prob;
unsigned int (*coef_counts)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES + 1] =
unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] =
counts->coef[tx_size][type][ref];
unsigned int (*eob_branch_count)[PREV_COEF_CONTEXTS] =
unsigned int (*eob_branch_count)[COEFF_CONTEXTS] =
counts->eob_branch[tx_size][type][ref];
uint8_t token_cache[32 * 32];
const uint8_t *cat6;
......
......@@ -553,7 +553,7 @@ static void write_modes(VP9_COMP *cpi, const TileInfo *const tile,
static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE tx_size) {
vp9_coeff_probs_model *coef_probs = cpi->frame_coef_probs[tx_size];
vp9_coeff_count *coef_counts = cpi->coef_counts[tx_size];
unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
cpi->common.counts.eob_branch[tx_size];
vp9_coeff_stats *coef_branch_ct = cpi->frame_branch_ct[tx_size];
int i, j, k, l, m;
......@@ -561,9 +561,7 @@ static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE tx_size) {
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
vp9_tree_probs_from_distribution(vp9_coef_tree,
coef_branch_ct[i][j][k][l],
coef_counts[i][j][k][l]);
......@@ -606,15 +604,12 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
for (t = 0; t < entropy_nodes_update; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
const vp9_prob oldp = old_frame_coef_probs[i][j][k][l][t];
int s;
int u = 0;
if (l >= 3 && k == 0)
continue;
if (t == PIVOT_NODE)
s = vp9_prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
......@@ -645,7 +640,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
// calc probs and branch cts for this frame only
for (t = 0; t < entropy_nodes_update; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
......@@ -653,8 +648,6 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
const vp9_prob upd = DIFF_UPDATE_PROB;
int s;
int u = 0;
if (l >= 3 && k == 0)
continue;
if (t == PIVOT_NODE)
s = vp9_prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
......@@ -686,25 +679,23 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
case 1:
case 2: {
const int prev_coef_contexts_to_update =
(cpi->sf.use_fast_coef_updates == 2 ?
PREV_COEF_CONTEXTS >> 1 : PREV_COEF_CONTEXTS);
cpi->sf.use_fast_coef_updates == 2 ? COEFF_CONTEXTS >> 1
: COEFF_CONTEXTS;
const int coef_band_to_update =
(cpi->sf.use_fast_coef_updates == 2 ?
COEF_BANDS >> 1 : COEF_BANDS);
cpi->sf.use_fast_coef_updates == 2 ? COEF_BANDS >> 1
: COEF_BANDS;
int updates = 0;
int noupdates_before_first = 0;
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
// calc probs and branch cts for this frame only
for (t = 0; t < entropy_nodes_update; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
vp9_prob *oldp = old_frame_coef_probs[i][j][k][l] + t;
int s;
int u = 0;
if (l >= 3 && k == 0)
continue;
if (l >= prev_coef_contexts_to_update ||
k >= coef_band_to_update) {
u = 0;
......
......@@ -87,7 +87,7 @@ struct macroblock_plane {
/* The [2] dimension is for whether we skip the EOB node (i.e. if previous
* coefficient in this block was zero) or not. */
typedef unsigned int vp9_coeff_cost[BLOCK_TYPES][REF_TYPES][COEF_BANDS][2]
[PREV_COEF_CONTEXTS][ENTROPY_TOKENS];
[COEFF_CONTEXTS][ENTROPY_TOKENS];
typedef struct macroblock MACROBLOCK;
struct macroblock {
......
......@@ -2614,17 +2614,15 @@ static void full_to_model_count(unsigned int *model_count,
model_count[EOB_MODEL_TOKEN] = full_count[EOB_TOKEN];
}
static void full_to_model_counts(
vp9_coeff_count_model *model_count, vp9_coeff_count *full_count) {
static void full_to_model_counts(vp9_coeff_count_model *model_count,
vp9_coeff_count *full_count) {
int i, j, k, l;
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l)
full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]);
}
}
#if 0 && CONFIG_INTERNAL_STATS
......
......@@ -154,11 +154,11 @@ static void fill_token_costs(vp9_coeff_cost *c,
vp9_coeff_probs_model (*p)[BLOCK_TYPES]) {
int i, j, k, l;
TX_SIZE t;
for (t = TX_4X4; t <= TX_32X32; t++)
for (i = 0; i < BLOCK_TYPES; i++)
for (j = 0; j < REF_TYPES; j++)
for (k = 0; k < COEF_BANDS; k++)
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
for (t = TX_4X4; t <= TX_32X32; ++t)
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
vp9_prob probs[ENTROPY_NODES];
vp9_model_to_full_probs(p[t][i][j][k][l], probs);
vp9_cost_tokens((int *)c[t][i][j][k][0][l], probs,
......@@ -528,7 +528,7 @@ static INLINE int cost_coeffs(MACROBLOCK *x,
const int eob = p->eobs[block];
const int16_t *const qcoeff_ptr = BLOCK_OFFSET(p->qcoeff, block);
const int ref = mbmi->ref_frame[0] != INTRA_FRAME;
unsigned int (*token_costs)[2][PREV_COEF_CONTEXTS][ENTROPY_TOKENS] =
unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
x->token_costs[tx_size][type][ref];
const ENTROPY_CONTEXT above_ec = !!*A, left_ec = !!*L;
uint8_t *p_tok = x->token_cache;
......
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