#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.
-#define MAX_NEIGHBORS 2
-int vp9_get_coef_context(const int *scan, const int *neighbors,
- int nb_pad, uint8_t *token_cache, int c, int l) {
- int eob = l;
- assert(nb_pad == MAX_NEIGHBORS);
- if (c == eob) {
- return 0;
- } else {
- int ctx;
- assert(neighbors[MAX_NEIGHBORS * c + 0] >= 0);
- if (neighbors[MAX_NEIGHBORS * c + 1] >= 0) {
- ctx = (1 + token_cache[scan[neighbors[MAX_NEIGHBORS * c + 0]]] +
- token_cache[scan[neighbors[MAX_NEIGHBORS * c + 1]]]) >> 1;
- } else {
- ctx = token_cache[scan[neighbors[MAX_NEIGHBORS * c + 0]]];
- }
- return ctx;
- }
-};
-
void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs[TX_4X4], default_coef_probs_4x4,
sizeof(pc->fc.coef_probs[TX_4X4]));
? (COEF_BANDS-1) : band_translate[coef_index];
}
-extern int vp9_get_coef_context(const int *scan, const int *neighbors,
- int nb_pad, uint8_t *token_cache, int c, int l);
+#define MAX_NEIGHBORS 2
+static INLINE int get_coef_context(const int *scan, const int *neighbors,
+ int nb_pad, uint8_t *token_cache,
+ int c, int l) {
+ int eob = l;
+ assert(nb_pad == MAX_NEIGHBORS);
+ if (c == eob) {
+ return 0;
+ } else {
+ int ctx;
+ assert(neighbors[MAX_NEIGHBORS * c + 0] >= 0);
+ if (neighbors[MAX_NEIGHBORS * c + 1] >= 0) {
+ ctx = (1 + token_cache[scan[neighbors[MAX_NEIGHBORS * c + 0]]] +
+ token_cache[scan[neighbors[MAX_NEIGHBORS * c + 1]]]) >> 1;
+ } else {
+ ctx = token_cache[scan[neighbors[MAX_NEIGHBORS * c + 0]]];
+ }
+ return ctx;
+ }
+}
+
const int *vp9_get_coef_neighbors_handle(const int *scan, int *pad);
if (c >= seg_eob)
break;
if (c)
- pt = vp9_get_coef_context(scan, nb, pad, token_cache,
- c, default_eob);
+ pt = get_coef_context(scan, nb, pad, token_cache,
+ c, default_eob);
band = get_coef_band(band_translate, c);
prob = coef_probs[band][pt];
#if !CONFIG_BALANCED_COEFTREE
if (c >= seg_eob)
break;
if (c)
- pt = vp9_get_coef_context(scan, nb, pad, token_cache,
- c, default_eob);
+ pt = get_coef_context(scan, nb, pad, token_cache,
+ c, default_eob);
band = get_coef_band(band_translate, c);
prob = coef_probs[band][pt];
int pad, int l) {
int bak = token_cache[scan[idx]], pt;
token_cache[scan[idx]] = vp9_pt_energy_class[token];
- pt = vp9_get_coef_context(scan, nb, pad, token_cache, idx + 1, l);
+ pt = get_coef_context(scan, nb, pad, token_cache, idx + 1, l);
token_cache[scan[idx]] = bak;
return pt;
}
v = qcoeff_ptr[rc];
t = vp9_dct_value_tokens_ptr[v].token;
- pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+ pt = get_coef_context(scan, nb, pad, token_cache, c, default_eob);
cost += token_costs[!prev_t][band][pt][t] + vp9_dct_value_cost_ptr[v];
token_cache[rc] = vp9_pt_energy_class[t];
prev_t = t;
// eob token
if (c < seg_eob) {
- pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+ pt = get_coef_context(scan, nb, pad, token_cache, c, default_eob);
cost += token_costs[0][get_coef_band(band_translate, c)][pt]
[DCT_EOB_TOKEN];
}
int v = 0;
rc = scan[c];
if (c)
- pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+ pt = get_coef_context(scan, nb, pad, token_cache, c, default_eob);
if (c < eob) {
v = qcoeff_ptr[rc];
assert(-DCT_MAX_VALUE <= v && v < DCT_MAX_VALUE);