Change to band calculation.
Change band calculation back to simpler model based on the order in which coefficients are coded in scan order not the absolute coefficient positions. With the scatter scan experiment enabled the results were appear broadly neutral on derf (-0.028) but up a little on std-hd +0.134). Without the scatterscan experiment on the results were up derf as well. Change-Id: Ie9ef03ce42a6b24b849a4bebe950d4a5dffa6791
This commit is contained in:
parent
5f221e7ac4
commit
e5f715201a
@ -46,6 +46,13 @@ DECLARE_ALIGNED(16, const int, vp9_coef_bands8x8[64]) = {
|
||||
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,
|
||||
@ -53,6 +60,12 @@ DECLARE_ALIGNED(16, const int, vp9_coef_bands4x4[16]) = {
|
||||
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
|
||||
};
|
||||
|
@ -133,20 +133,20 @@ static INLINE void vp9_reset_sb_tokens_context(MACROBLOCKD* const xd,
|
||||
|
||||
extern const int vp9_coef_bands8x8[64];
|
||||
extern const int vp9_coef_bands4x4[16];
|
||||
extern const uint8_t vp9_coefband_trans_8x8plus[22];
|
||||
extern const uint8_t vp9_coefband_trans_4x4[22];
|
||||
|
||||
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];
|
||||
}
|
||||
// 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);
|
||||
|
@ -1105,8 +1105,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,6 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
|
||||
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)) \
|
||||
@ -104,6 +98,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
TX_TYPE tx_type = DCT_DCT;
|
||||
const int *scan, *nb;
|
||||
uint8_t token_cache[1024];
|
||||
const uint8_t * band_translate;
|
||||
|
||||
switch (txfm_size) {
|
||||
default:
|
||||
@ -116,6 +111,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
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: {
|
||||
@ -131,6 +127,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
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: {
|
||||
@ -146,6 +143,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
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:
|
||||
@ -155,6 +153,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -169,7 +168,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
|
||||
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]))
|
||||
@ -181,8 +180,9 @@ SKIP_START:
|
||||
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;
|
||||
|
@ -139,6 +139,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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);
|
||||
@ -149,23 +150,27 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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);
|
||||
@ -204,7 +209,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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 +=
|
||||
@ -254,7 +259,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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);
|
||||
@ -291,7 +296,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
* 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. */
|
||||
@ -310,7 +315,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
@ -272,6 +272,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
[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));
|
||||
@ -291,6 +292,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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: {
|
||||
@ -304,6 +306,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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: {
|
||||
@ -317,6 +320,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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:
|
||||
@ -325,6 +329,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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();
|
||||
@ -347,7 +352,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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);
|
||||
|
||||
@ -361,7 +366,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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) {
|
||||
@ -149,6 +150,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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: {
|
||||
@ -162,6 +164,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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: {
|
||||
@ -175,6 +178,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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:
|
||||
@ -184,6 +188,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -196,7 +201,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
|
||||
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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user