summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_rdopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_rdopt.c')
-rw-r--r--vp9/encoder/vp9_rdopt.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 04b732a45..8ba2220d6 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -156,21 +156,9 @@ 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_CODE_NONZEROCOUNT
- // All costs are without the EOB node
vp9_cost_tokens_skip((int *)(c[i][j][k][l]),
p[i][j][k][l],
vp9_coef_tree);
-#else
- if (l == 0 && k > 0)
- vp9_cost_tokens_skip((int *)(c[i][j][k][l]),
- p[i][j][k][l],
- vp9_coef_tree);
- else
- vp9_cost_tokens((int *)(c[i][j][k][l]),
- p[i][j][k][l],
- vp9_coef_tree);
-#endif
}
}
@@ -448,8 +436,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
int pt;
const int eob = xd->eobs[ib];
int c = 0;
- int cost = 0;
- const int *scan;
+ int cost = 0, pad;
+ const int *scan, *nb;
const int16_t *qcoeff_ptr = xd->qcoeff + ib * 16;
const int ref = mbmi->ref_frame != INTRA_FRAME;
unsigned int (*token_costs)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] =
@@ -464,9 +452,12 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
int nzc_context = vp9_get_nzc_context(cm, xd, ib);
unsigned int *nzc_cost;
#else
- int seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
+ vp9_prob (*coef_probs)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
+ [ENTROPY_NODES];
#endif
+ int seg_eob, default_eob;
+ uint8_t token_cache[1024];
// Check for consistency of tx_size with mode info
if (type == PLANE_TYPE_Y_WITH_DC) {
@@ -485,8 +476,9 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_4x4[nzc_context][ref][type];
#else
- seg_eob = 16;
+ coef_probs = cm->fc.coef_probs_4x4;
#endif
+ seg_eob = 16;
if (tx_type == ADST_DCT) {
scan = vp9_row_scan_4x4;
} else if (tx_type == DCT_ADST) {
@@ -503,16 +495,18 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_8x8[nzc_context][ref][type];
#else
- seg_eob = 64;
+ coef_probs = cm->fc.coef_probs_8x8;
#endif
+ seg_eob = 64;
break;
case TX_16X16:
scan = vp9_default_zig_zag1d_16x16;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_16x16[nzc_context][ref][type];
#else
- seg_eob = 256;
+ coef_probs = cm->fc.coef_probs_16x16;
#endif
+ seg_eob = 256;
if (type == PLANE_TYPE_UV) {
a_ec = (a[0] + a[1] + a1[0] + a1[1]) != 0;
l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
@@ -526,8 +520,9 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_32x32[nzc_context][ref][type];
#else
- seg_eob = 1024;
+ coef_probs = cm->fc.coef_probs_32x32;
#endif
+ seg_eob = 1024;
if (type == PLANE_TYPE_UV) {
ENTROPY_CONTEXT *a2, *a3, *l2, *l3;
a2 = a1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT);
@@ -551,6 +546,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
VP9_COMBINEENTROPYCONTEXTS(pt, a_ec, l_ec);
+ nb = vp9_get_coef_neighbors_handle(scan, &pad);
+ default_eob = seg_eob;
#if CONFIG_CODE_NONZEROCOUNT == 0
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
@@ -558,7 +555,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#endif
{
- int recent_energy = 0;
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
@@ -568,9 +564,16 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#if CONFIG_CODE_NONZEROCOUNT
nzc += (v != 0);
#endif
+ token_cache[c] = t;
cost += token_costs[get_coef_band(tx_size, c)][pt][t];
cost += vp9_dct_value_cost_ptr[v];
- pt = vp9_get_coef_context(&recent_energy, t);
+#if !CONFIG_CODE_NONZEROCOUNT
+ if (!c || token_cache[c - 1])
+ cost += vp9_cost_bit(coef_probs[type][ref]
+ [get_coef_band(tx_size, c)]
+ [pt][0], 1);
+#endif
+ pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
}
#if CONFIG_CODE_NONZEROCOUNT
cost += nzc_cost[nzc];