diff --git a/configure b/configure index 136f253f8..5cdb45288 100755 --- a/configure +++ b/configure @@ -245,7 +245,6 @@ EXPERIMENT_LIST=" comp_interintra_pred tx64x64 cnvcontext - newcoefcontext enable_6tap abovesprefmv intht diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index 01fa63fdb..c3d6dae93 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -219,8 +219,4 @@ void vp9_initialize_common() { vp9_entropy_mode_init(); vp9_entropy_mv_init(); - -#if CONFIG_NEWCOEFCONTEXT - vp9_init_neighbors(); -#endif } diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index 03f89ac87..31ea2b5ef 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c @@ -318,146 +318,6 @@ vp9_extra_bit_struct vp9_extra_bits[12] = { #include "vp9/common/vp9_default_coef_probs.h" -#if CONFIG_NEWCOEFCONTEXT - -// Neighborhood 5-tuples for various scans and blocksizes, -// in {top, left, topleft, topright, bottomleft} order -// for each position in raster scan order. -// -1 indicates the neighbor does not exist. -DECLARE_ALIGNED(16, int, - vp9_default_zig_zag1d_4x4_neighbors[16 * MAX_NEIGHBORS]); -DECLARE_ALIGNED(16, int, - vp9_col_scan_4x4_neighbors[16 * MAX_NEIGHBORS]); -DECLARE_ALIGNED(16, int, - vp9_row_scan_4x4_neighbors[16 * MAX_NEIGHBORS]); -DECLARE_ALIGNED(16, int, - vp9_default_zig_zag1d_8x8_neighbors[64 * MAX_NEIGHBORS]); -DECLARE_ALIGNED(16, int, - vp9_default_zig_zag1d_16x16_neighbors[256 * MAX_NEIGHBORS]); -DECLARE_ALIGNED(16, int, - vp9_default_zig_zag1d_32x32_neighbors[1024 * MAX_NEIGHBORS]); - -static int find_in_scan(const int *scan, int l, int m) { - int i, l2 = l * l; - for (i = 0; i < l2; ++i) { - if (scan[i] == m) - return i; - } - return -1; -} - -static void init_scan_neighbors(const int *scan, int l, int *neighbors) { - int l2 = l * l; - int m, n, i, j, k; - for (n = 0; n < l2; ++n) { - int locn = find_in_scan(scan, l, n); - int z = -1; - i = n / l; - j = n % l; - for (k = 0; k < MAX_NEIGHBORS; ++k) - neighbors[MAX_NEIGHBORS * n + k] = -1; - if (i - 1 >= 0) { - m = (i - 1) * l + j; - if (find_in_scan(scan, l, m) < locn) { - neighbors[MAX_NEIGHBORS * n] = m; - if (m == 0) z = 0; - } - } - if (j - 1 >= 0) { - m = i * l + j - 1; - if (find_in_scan(scan, l, m) < locn) { - neighbors[MAX_NEIGHBORS * n + 1] = m; - if (m == 0) z = 1; - } - } - if (i - 1 >= 0 && j - 1 >= 0) { - m = (i - 1) * l + j - 1; - if (find_in_scan(scan, l, m) < locn) { - neighbors[MAX_NEIGHBORS * n + 2] = m; - if (m == 0) z = 2; - } - } - if (i - 1 >= 0 && j + 1 < l) { - m = (i - 1) * l + j + 1; - if (find_in_scan(scan, l, m) < locn) { - neighbors[MAX_NEIGHBORS * n + 3] = m; - if (m == 0) z = 3; - } - } - if (i + 1 < l && j - 1 >= 0) { - m = (i + 1) * l + j - 1; - if (find_in_scan(scan, l, m) < locn) { - neighbors[MAX_NEIGHBORS * n + 4] = m; - if (m == 0) z = 4; - } - } - if (z != -1) { // zero exists - int v = 0; - for (k = 0; k < MAX_NEIGHBORS; ++k) - v += (neighbors[MAX_NEIGHBORS * n + k] > 0); - if (v) { - neighbors[MAX_NEIGHBORS * n + z] = -1; - } - } - } -} - -void vp9_init_neighbors() { - init_scan_neighbors(vp9_default_zig_zag1d_4x4, 4, - vp9_default_zig_zag1d_4x4_neighbors); - init_scan_neighbors(vp9_row_scan_4x4, 4, - vp9_row_scan_4x4_neighbors); - init_scan_neighbors(vp9_col_scan_4x4, 4, - vp9_col_scan_4x4_neighbors); - init_scan_neighbors(vp9_default_zig_zag1d_8x8, 8, - vp9_default_zig_zag1d_8x8_neighbors); - init_scan_neighbors(vp9_default_zig_zag1d_16x16, 16, - vp9_default_zig_zag1d_16x16_neighbors); - init_scan_neighbors(vp9_default_zig_zag1d_32x32, 32, - vp9_default_zig_zag1d_32x32_neighbors); -} - -const int *vp9_get_coef_neighbors_handle(const int *scan) { - if (scan == vp9_default_zig_zag1d_4x4) { - return vp9_default_zig_zag1d_4x4_neighbors; - } else if (scan == vp9_row_scan_4x4) { - return vp9_row_scan_4x4_neighbors; - } else if (scan == vp9_col_scan_4x4) { - return vp9_col_scan_4x4_neighbors; - } else if (scan == vp9_default_zig_zag1d_8x8) { - return vp9_default_zig_zag1d_8x8_neighbors; - } else if (scan == vp9_default_zig_zag1d_16x16) { - return vp9_default_zig_zag1d_16x16_neighbors; - } else if (scan == vp9_default_zig_zag1d_32x32) { - return vp9_default_zig_zag1d_32x32_neighbors; - } - return vp9_default_zig_zag1d_4x4_neighbors; -} - -int vp9_get_coef_neighbor_context(const short int *qcoeff_ptr, int nodc, - const int *neigbor_handle, int rc) { - static int neighbors_used = MAX_NEIGHBORS; // maximum is MAX_NEIGHBORS - const int *nb = neigbor_handle + rc * MAX_NEIGHBORS; - int i, v, val = 0, n = 0; - for (i = 0; i < neighbors_used; ++i) { - if (nb[i] == -1 || (nb[i] == 0 && nodc)) { - continue; - } - v = abs(qcoeff_ptr[nb[i]]); - val = (v > val ? v : val); - n++; - } - if (n == 0) - return 0; - else if (val <= 1) - return val; - else if (val < 4) - return 2; - else - return 3; -} -#endif /* CONFIG_NEWCOEFCONTEXT */ - 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)); diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 84e5255c2..c6f51e0c6 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -129,26 +129,4 @@ static void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) { vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)); } -#if CONFIG_NEWCOEFCONTEXT - -#define MAX_NEIGHBORS 5 -#define NEWCOEFCONTEXT_BAND_COND(b) ((b) >= 1) -void vp9_init_neighbors(void); - -const int *vp9_get_coef_neighbors_handle(const int *scan); -int vp9_get_coef_neighbor_context(const short int *qcoeff_ptr, int nodc, - const int *neigbor_handle, int rc); -extern DECLARE_ALIGNED(16, int, vp9_default_zig_zag1d_4x4_neighbors[ - 16 * MAX_NEIGHBORS]); -extern DECLARE_ALIGNED(16, int, vp9_row_scan_4x4_neighbors[ - 16 * MAX_NEIGHBORS]); -extern DECLARE_ALIGNED(16, int, vp9_col_scan_4x4_neighbors[ - 16 * MAX_NEIGHBORS]); -extern DECLARE_ALIGNED(16, int, vp9_default_zig_zag1d_8x8_neighbors[ - 64 * MAX_NEIGHBORS]); -extern DECLARE_ALIGNED(16, int, vp9_default_zig_zag1d_16x16_neighbors[ - 256 * MAX_NEIGHBORS]); -extern DECLARE_ALIGNED(16, int, vp9_default_zig_zag1d_32x32_neighbors[ - 1024 * MAX_NEIGHBORS]); -#endif // CONFIG_NEWCOEFCONTEXT #endif // VP9_COMMON_VP9_ENTROPY_H_ diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index acf69d906..9e1df063c 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -63,24 +63,11 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) { return decode_bool(br, 128) ? -value_to_sign : value_to_sign; } -#if CONFIG_NEWCOEFCONTEXT -#define PT pn -#define INCREMENT_COUNT(token) \ - do { \ - coef_counts[type][coef_bands[c]][pn][token]++; \ - pn = pt = vp9_prev_token_class[token]; \ - if (c < seg_eob - 1 && NEWCOEFCONTEXT_BAND_COND(coef_bands[c + 1])) \ - pn = vp9_get_coef_neighbor_context( \ - qcoeff_ptr, nodc, neighbors, scan[c + 1]); \ - } while (0) -#else -#define PT pt #define INCREMENT_COUNT(token) \ do { \ coef_counts[type][coef_bands[c]][pt][token]++; \ pt = vp9_prev_token_class[token]; \ } while (0) -#endif /* CONFIG_NEWCOEFCONTEXT */ #define WRITE_COEF_CONTINUE(val, token) \ { \ @@ -108,10 +95,6 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, 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; -#if CONFIG_NEWCOEFCONTEXT - const int *neighbors; - int pn; -#endif int nodc = (type == PLANE_TYPE_Y_NO_DC); int pt, c = nodc; vp9_coeff_probs *coef_probs; @@ -192,15 +175,11 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, } VP9_COMBINEENTROPYCONTEXTS(pt, above_ec, left_ec); -#if CONFIG_NEWCOEFCONTEXT - pn = pt; - neighbors = vp9_get_coef_neighbors_handle(scan); -#endif while (1) { int val; const uint8_t *cat6 = cat6_prob; if (c >= seg_eob) break; - prob = coef_probs[type][coef_bands[c]][PT]; + prob = coef_probs[type][coef_bands[c]][pt]; if (!vp9_read(br, prob[EOB_CONTEXT_NODE])) break; SKIP_START: @@ -208,7 +187,7 @@ SKIP_START: if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) { INCREMENT_COUNT(ZERO_TOKEN); ++c; - prob = coef_probs[type][coef_bands[c]][PT]; + prob = coef_probs[type][coef_bands[c]][pt]; goto SKIP_START; } // ONE_CONTEXT_NODE_0_ @@ -272,7 +251,7 @@ SKIP_START: } if (c < seg_eob) - coef_counts[type][coef_bands[c]][PT][DCT_EOB_TOKEN]++; + coef_counts[type][coef_bands[c]][pt][DCT_EOB_TOKEN]++; A0[aidx] = L0[lidx] = (c > !type); if (txfm_size >= TX_8X8 && type != PLANE_TYPE_Y2) { diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 52eabf129..1f5657ea0 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -380,9 +380,6 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, int err_mult = plane_rd_mult[type]; int default_eob; int const *scan, *bands; -#if CONFIG_NEWCOEFCONTEXT - const int *neighbors; -#endif switch (tx_size) { default: @@ -424,9 +421,6 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, default_eob = 256; break; } -#if CONFIG_NEWCOEFCONTEXT - neighbors = vp9_get_coef_neighbors_handle(scan); -#endif /* Now set up a Viterbi trellis to evaluate alternative roundings. */ rdmult = mb->rdmult * err_mult; @@ -460,11 +454,6 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, if (next < default_eob) { band = bands[i + 1]; pt = vp9_prev_token_class[t0]; -#if CONFIG_NEWCOEFCONTEXT - if (NEWCOEFCONTEXT_BAND_COND(band)) - pt = vp9_get_coef_neighbor_context( - qcoeff_ptr, i0, neighbors, scan[i + 1]); -#endif rate0 += mb->token_costs[tx_size][type][band][pt][tokens[next][0].token]; rate1 += @@ -512,34 +501,12 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, if (next < default_eob) { band = bands[i + 1]; if (t0 != DCT_EOB_TOKEN) { -#if CONFIG_NEWCOEFCONTEXT - int tmp = qcoeff_ptr[scan[i]]; - qcoeff_ptr[scan[i]] = x; - if (NEWCOEFCONTEXT_BAND_COND(band)) - pt = vp9_get_coef_neighbor_context( - qcoeff_ptr, i0, neighbors, scan[i + 1]); - else - pt = vp9_prev_token_class[t0]; - qcoeff_ptr[scan[i]] = tmp; -#else pt = vp9_prev_token_class[t0]; -#endif rate0 += mb->token_costs[tx_size][type][band][pt][ tokens[next][0].token]; } if (t1 != DCT_EOB_TOKEN) { -#if CONFIG_NEWCOEFCONTEXT - int tmp = qcoeff_ptr[scan[i]]; - qcoeff_ptr[scan[i]] = x; - if (NEWCOEFCONTEXT_BAND_COND(band)) - pt = vp9_get_coef_neighbor_context( - qcoeff_ptr, i0, neighbors, scan[i + 1]); - else - pt = vp9_prev_token_class[t1]; - qcoeff_ptr[scan[i]] = tmp; -#else pt = vp9_prev_token_class[t1]; -#endif rate1 += mb->token_costs[tx_size][type][band][pt][ tokens[next][1].token]; } diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 80a88884b..a03df4a5b 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -419,11 +419,6 @@ int vp9_uvsse(MACROBLOCK *x) { } -#if CONFIG_NEWCOEFCONTEXT -#define PT pn -#else -#define PT pt -#endif static INLINE int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, PLANE_TYPE type, ENTROPY_CONTEXT *a, @@ -443,11 +438,6 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, unsigned int (*token_costs)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] = (tx_type == DCT_DCT) ? mb->token_costs[tx_size][type] : mb->hybrid_token_costs[tx_size][type]; -#if CONFIG_NEWCOEFCONTEXT - const int *neighbors; - int pn; -#endif - ENTROPY_CONTEXT a_ec = *a, l_ec = *l; switch (tx_size) { @@ -495,10 +485,6 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, } VP9_COMBINEENTROPYCONTEXTS(pt, a_ec, l_ec); -#if CONFIG_NEWCOEFCONTEXT - neighbors = vp9_get_coef_neighbors_handle(scan); - pn = pt; -#endif if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) seg_eob = 0; @@ -507,20 +493,13 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, 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 += token_costs[band[c]][pt][t]; cost += vp9_dct_value_cost_ptr[v]; pt = vp9_prev_token_class[t]; -#if CONFIG_NEWCOEFCONTEXT - if (c < seg_eob - 1 && NEWCOEFCONTEXT_BAND_COND(band[c + 1])) - pn = vp9_get_coef_neighbor_context( - qcoeff_ptr, (type == PLANE_TYPE_Y_NO_DC), neighbors, scan[c + 1]); - else - pn = pt; -#endif } if (c < seg_eob) cost += mb->hybrid_token_costs[tx_size][type][band[c]] - [PT][DCT_EOB_TOKEN]; + [pt][DCT_EOB_TOKEN]; } else { for (; c < eob; c++) { int v = qcoeff_ptr[scan[c]]; @@ -528,17 +507,10 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, cost += token_costs[band[c]][pt][t]; cost += vp9_dct_value_cost_ptr[v]; pt = vp9_prev_token_class[t]; -#if CONFIG_NEWCOEFCONTEXT - if (c < seg_eob - 1 && NEWCOEFCONTEXT_BAND_COND(band[c + 1])) - pn = vp9_get_coef_neighbor_context( - qcoeff_ptr, (type == PLANE_TYPE_Y_NO_DC), neighbors, scan[c + 1]); - else - pn = pt; -#endif } if (c < seg_eob) cost += mb->token_costs[tx_size][type][band[c]] - [PT][DCT_EOB_TOKEN]; + [pt][DCT_EOB_TOKEN]; } // is eob first coefficient; diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 2dedb1a51..25b29d588 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -100,12 +100,6 @@ static void fill_value_tokens() { vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; } -#if CONFIG_NEWCOEFCONTEXT -#define PT pn -#else -#define PT pt -#endif - static void tokenize_b(VP9_COMP *cpi, MACROBLOCKD *xd, const int ib, @@ -126,10 +120,6 @@ static void tokenize_b(VP9_COMP *cpi, vp9_coeff_probs *probs; const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type(xd, b) : DCT_DCT; -#if CONFIG_NEWCOEFCONTEXT - const int *neighbors; - int pn; -#endif ENTROPY_CONTEXT *const a = (ENTROPY_CONTEXT *)xd->above_context + vp9_block2above[tx_size][ib]; @@ -228,10 +218,6 @@ static void tokenize_b(VP9_COMP *cpi, } VP9_COMBINEENTROPYCONTEXTS(pt, a_ec, l_ec); -#if CONFIG_NEWCOEFCONTEXT - neighbors = vp9_get_coef_neighbors_handle(scan); - pn = pt; -#endif if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) seg_eob = 0; @@ -252,21 +238,14 @@ static void tokenize_b(VP9_COMP *cpi, } t->Token = token; - t->context_tree = probs[type][band][PT]; + t->context_tree = probs[type][band][pt]; t->skip_eob_node = (pt == 0) && ((band > 0 && type != PLANE_TYPE_Y_NO_DC) || (band > 1 && type == PLANE_TYPE_Y_NO_DC)); assert(vp9_coef_encodings[t->Token].Len - t->skip_eob_node > 0); if (!dry_run) { - ++counts[type][band][PT][token]; + ++counts[type][band][pt][token]; } pt = vp9_prev_token_class[token]; -#if CONFIG_NEWCOEFCONTEXT - if (c < seg_eob - 1 && NEWCOEFCONTEXT_BAND_COND(bands[c + 1])) - pn = vp9_get_coef_neighbor_context( - qcoeff_ptr, (type == PLANE_TYPE_Y_NO_DC), neighbors, scan[c + 1]); - else - pn = pt; -#endif ++t; } while (c < eob && ++c < seg_eob);