#include "vp9/common/vp9_default_coef_probs.h"
+// This function updates and then returns n AC coefficient context
+// This is currently a placeholder function to allow experimentation
+// using various context models based on the energy earlier tokens
+// within the current block.
+//
+// For now it just returns the previously used context.
+int vp9_get_coef_context(int * recent_energy, int token) {
+ // int token_energy;
+ // int av_energy;
+
+ // Placeholder code for experiments with token energy
+ // as a coefficient context.
+ /*token_energy = ((token != DCT_EOB_TOKEN) ? token : 0);
+ if (token_energy) {
+ av_energy = (token_energy + *recent_energy + 1) >> 1;
+ } else {
+ av_energy = 0;
+ }
+ *recent_energy = token_energy;*/
+
+ return vp9_prev_token_class[token];
+};
+
void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs_4x4, default_coef_probs_4x4,
sizeof(pc->fc.coef_probs_4x4));
#define SUBEXP_PARAM 4 /* Subexponential code parameter */
#define MODULUS_PARAM 13 /* Modulus parameter */
-extern DECLARE_ALIGNED(16, const uint8_t,
- vp9_prev_token_class[MAX_ENTROPY_TOKENS]);
-
struct VP9Common;
void vp9_default_coef_probs(struct VP9Common *);
extern DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d_4x4[16]);
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
}
+extern int vp9_get_coef_context(int * recent_energy, int token);
#endif // VP9_COMMON_VP9_ENTROPY_H_
#define INCREMENT_COUNT(token) \
do { \
- coef_counts[type][coef_bands[c]][pt][token]++; \
- pt = vp9_prev_token_class[token]; \
+ coef_counts[type][coef_bands[c]][pt][token]++; \
+ pt = vp9_get_coef_context(&recent_energy, token); \
} while (0)
#define WRITE_COEF_CONTINUE(val, token) \
const int lidx = vp9_block2left[txfm_size][block_idx];
ENTROPY_CONTEXT above_ec = A0[aidx] != 0, left_ec = L0[lidx] != 0;
FRAME_CONTEXT *const fc = &dx->common.fc;
+ int recent_energy = 0;
int nodc = (type == PLANE_TYPE_Y_NO_DC);
int pt, c = nodc;
vp9_coeff_probs *coef_probs;
}\
}
+// This function is a place holder for now but may ultimately need
+// to scan previous tokens to work out the correct context.
+static int trellis_get_coeff_context(int token) {
+ int recent_energy = 0;
+ return vp9_get_coef_context(&recent_energy, token);
+}
+
static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int tx_size) {
/* Consider both possible successor states. */
if (next < default_eob) {
band = bands[i + 1];
- pt = vp9_prev_token_class[t0];
+ pt = trellis_get_coeff_context(t0);
rate0 +=
mb->token_costs[tx_size][type][band][pt][tokens[next][0].token];
rate1 +=
if (next < default_eob) {
band = bands[i + 1];
if (t0 != DCT_EOB_TOKEN) {
- pt = vp9_prev_token_class[t0];
+ pt = trellis_get_coeff_context(t0);
rate0 += mb->token_costs[tx_size][type][band][pt][
tokens[next][0].token];
}
if (t1 != DCT_EOB_TOKEN) {
- pt = vp9_prev_token_class[t1];
+ pt = trellis_get_coeff_context(t1);
rate1 += mb->token_costs[tx_size][type][band][pt][
tokens[next][1].token];
}
seg_eob = 0;
if (tx_type != DCT_DCT) {
+ int recent_energy = 0;
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].Token;
cost += token_costs[band[c]][pt][t];
cost += vp9_dct_value_cost_ptr[v];
- pt = vp9_prev_token_class[t];
+ pt = vp9_get_coef_context(&recent_energy, t);
}
if (c < seg_eob)
cost += mb->hybrid_token_costs[tx_size][type][band[c]]
[pt][DCT_EOB_TOKEN];
} else {
+ int recent_energy = 0;
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].Token;
cost += token_costs[band[c]][pt][t];
cost += vp9_dct_value_cost_ptr[v];
- pt = vp9_prev_token_class[t];
+ pt = vp9_get_coef_context(&recent_energy, t);
}
if (c < seg_eob)
cost += mb->token_costs[tx_size][type][band[c]]
// TODO(jingning) is it possible to quickly determine whether to force
// trailing coefficients to be zero, instead of running trellis
// optimization in the rate-distortion optimization loop?
- if (mb->optimize && mb->e_mbd.mode_info_context->mbmi.mode < I8X8_PRED)
+ if (mb->optimize &&
+ xd->mode_info_context->mbmi.mode < I8X8_PRED)
vp9_optimize_mby_16x16(mb);
d = vp9_mbblock_error(mb, 0);
int dry_run) {
int pt; /* near block/prev token context index */
int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0;
+ int recent_energy = 0;
const BLOCKD * const b = xd->block + ib;
const int eob = b->eob; /* one beyond last nonzero coeff */
TOKENEXTRA *t = *tp; /* store tokens starting here */
if (!dry_run) {
++counts[type][band][pt][token];
}
- pt = vp9_prev_token_class[token];
+
+ pt = vp9_get_coef_context(&recent_energy, token);
++t;
} while (c < eob && ++c < seg_eob);