5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5
};
+
+DECLARE_ALIGNED(16, const uint8_t,
+ vp9_coefband_trans_8x8plus[MAXBAND_INDEX + 1]) = {
+ 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5
+};
+
DECLARE_ALIGNED(16, const int, vp9_coef_bands4x4[16]) = {
0, 1, 2, 3,
1, 2, 3, 4,
3, 4, 5, 5
};
+DECLARE_ALIGNED(16, const uint8_t,
+ vp9_coefband_trans_4x4[MAXBAND_INDEX + 1]) = {
+ 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5
+};
+
DECLARE_ALIGNED(16, const uint8_t, vp9_pt_energy_class[MAX_ENTROPY_TOKENS]) = {
0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5
};
extern const int vp9_coef_bands8x8[64];
extern const int vp9_coef_bands4x4[16];
-
-static int get_coef_band(const int *scan, TX_SIZE tx_size, int coef_index) {
- if (tx_size == TX_4X4) {
- return vp9_coef_bands4x4[scan[coef_index]];
- } else {
- const int pos = scan[coef_index];
- const int sz = 1 << (2 + tx_size);
- const int x = pos & (sz - 1), y = pos >> (2 + tx_size);
- if (x >= 8 || y >= 8)
- return 5;
- else
- return vp9_coef_bands8x8[y * 8 + x];
- }
+extern const uint8_t vp9_coefband_trans_8x8plus[22];
+extern const uint8_t vp9_coefband_trans_4x4[22];
+
+// This is the index in the scan order beyond which all coefficients for
+// 8x8 transform and above are in the top band.
+// For 4x4 blocks the index is less but to keep things common the lookup
+// table for 4x4 is padded out to this index.
+#define MAXBAND_INDEX 21
+
+static int get_coef_band(const uint8_t * band_translate, int coef_index) {
+ return (coef_index > MAXBAND_INDEX)
+ ? (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);
const int *vp9_get_coef_neighbors_handle(const int *scan, int *pad);
if (pc->frame_type != KEY_FRAME) {
vp9_adapt_mode_probs(pc);
- vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv);
vp9_adapt_mode_context(pc);
+ vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv);
}
}
continue; \
}
-#define WRITE_COEF_ONE() \
-{ \
- qcoeff_ptr[scan[c]] = vp9_read_and_apply_sign(br, 1); \
- INCREMENT_COUNT(ONE_TOKEN); \
-}
-
#define ADJUST_COEF(prob, bits_count) \
do { \
if (vp9_read(r, prob)) \
TX_TYPE tx_type = DCT_DCT;
const int *scan, *nb;
uint8_t token_cache[1024];
+ const uint8_t * band_translate;
switch (txfm_size) {
default:
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
default_eob = 16;
+ band_translate = vp9_coefband_trans_4x4;
break;
}
case TX_8X8: {
above_ec = (A[0] + A[1]) != 0;
left_ec = (L[0] + L[1]) != 0;
default_eob = 64;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_16X16: {
above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
default_eob = 256;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_32X32:
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;
default_eob = 1024;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache,
c, default_eob);
- band = get_coef_band(scan, txfm_size, c);
+ band = get_coef_band(band_translate, c);
prob = coef_probs[type][ref][band][pt];
fc->eob_branch_counts[txfm_size][type][ref][band][pt]++;
if (!vp9_read(r, prob[EOB_CONTEXT_NODE]))
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache,
c, default_eob);
- band = get_coef_band(scan, txfm_size, c);
+ band = get_coef_band(band_translate, c);
prob = coef_probs[type][ref][band][pt];
+
if (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN);
++c;
const int ib = txfrm_block_to_raster_block(xd, bsize, plane,
block, 2 * tx_size);
const int16_t *dequant_ptr = xd->plane[plane].dequant;
+ const uint8_t * band_translate;
assert((!type && !plane) || (type && plane));
dqcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block, 16);
const TX_TYPE tx_type = plane == 0 ? get_tx_type_4x4(xd, ib) : DCT_DCT;
default_eob = 16;
scan = get_scan_4x4(tx_type);
+ band_translate = vp9_coefband_trans_4x4;
break;
}
case TX_8X8: {
const TX_TYPE tx_type = plane == 0 ? get_tx_type_8x8(xd, ib) : DCT_DCT;
scan = get_scan_8x8(tx_type);
default_eob = 64;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_16X16: {
const TX_TYPE tx_type = plane == 0 ? get_tx_type_16x16(xd, ib) : DCT_DCT;
scan = get_scan_16x16(tx_type);
default_eob = 256;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
default_eob = 1024;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
assert(eob <= default_eob);
t0 = (vp9_dct_value_tokens_ptr + x)->token;
/* Consider both possible successor states. */
if (next < default_eob) {
- band = get_coef_band(scan, tx_size, i + 1);
+ band = get_coef_band(band_translate, i + 1);
pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache,
pad, default_eob);
rate0 +=
t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token;
}
if (next < default_eob) {
- band = get_coef_band(scan, tx_size, i + 1);
+ band = get_coef_band(band_translate, i + 1);
if (t0 != DCT_EOB_TOKEN) {
pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache,
pad, default_eob);
* add a new trellis node, but we do need to update the costs.
*/
else {
- band = get_coef_band(scan, tx_size, i + 1);
+ band = get_coef_band(band_translate, i + 1);
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
/* Update the cost of each path if we're past the EOB token. */
}
/* Now pick the best path through the whole trellis. */
- band = get_coef_band(scan, tx_size, i + 1);
+ band = get_coef_band(band_translate, i + 1);
pt = combine_entropy_contexts(*a, *l);
rate0 = tokens[next][0].rate;
rate1 = tokens[next][1].rate;
[ENTROPY_NODES];
int seg_eob, default_eob;
uint8_t token_cache[1024];
+ const uint8_t * band_translate;
// Check for consistency of tx_size with mode info
assert((!type && !plane) || (type && plane));
coef_probs = cm->fc.coef_probs_4x4;
seg_eob = 16;
scan = get_scan_4x4(tx_type);
+ band_translate = vp9_coefband_trans_4x4;
break;
}
case TX_8X8: {
scan = get_scan_8x8(tx_type);
coef_probs = cm->fc.coef_probs_8x8;
seg_eob = 64;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_16X16: {
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;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_32X32:
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;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
default:
abort();
for (c = 0; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].token;
- int band = get_coef_band(scan, tx_size, c);
+ int band = get_coef_band(band_translate, c);
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
cost += mb->token_costs[tx_size][type][ref]
- [get_coef_band(scan, tx_size, c)]
+ [get_coef_band(band_translate, c)]
[pt][DCT_EOB_TOKEN];
}
}
ENTROPY_CONTEXT above_ec, left_ec;
uint8_t token_cache[1024];
TX_TYPE tx_type = DCT_DCT;
+ const uint8_t * band_translate;
assert((!type && !plane) || (type && plane));
switch (tx_size) {
scan = get_scan_4x4(tx_type);
counts = cpi->coef_counts_4x4;
coef_probs = cpi->common.fc.coef_probs_4x4;
+ band_translate = vp9_coefband_trans_4x4;
break;
}
case TX_8X8: {
scan = get_scan_8x8(tx_type);
counts = cpi->coef_counts_8x8;
coef_probs = cpi->common.fc.coef_probs_8x8;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_16X16: {
scan = get_scan_16x16(tx_type);
counts = cpi->coef_counts_16x16;
coef_probs = cpi->common.fc.coef_probs_16x16;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
counts = cpi->coef_counts_32x32;
coef_probs = cpi->common.fc.coef_probs_32x32;
+ band_translate = vp9_coefband_trans_8x8plus;
break;
}
c = 0;
do {
- const int band = get_coef_band(scan, tx_size, c);
+ const int band = get_coef_band(band_translate, c);
int token;
int v = 0;
rc = scan[c];