From 9255ad107f2e17685090c15555c0a80b6cd06854 Mon Sep 17 00:00:00 2001 From: Paul Wilkins Date: Mon, 11 Feb 2013 20:44:53 +0000 Subject: [PATCH] Abstract selection of coef band. This patch abstracts the selection of the coefficient band context into a function as a precursor to further experiments with the coefficient context. It also removes the large per TX size coefficient band structures and uses a single matrix for all block sizes within the test function. This may have an impact on quality (results to follow) but is only an intermediate step in the process of redefining the context. Also the quality impact will be larger initially because the default tables will be out of step with the new banding. In particular the 4x4 will in this case only use 7 bands. If needed we can add back block size dependency localized within the function, but this can follow on after the other changes to the definition of the context. Change-Id: Id7009c2f4f9bb1d02b861af85fd8223d4285bde5 --- vp9/common/vp9_entropy.c | 116 +++++-------------------------------------- vp9/common/vp9_entropy.h | 5 +- vp9/decoder/vp9_detokenize.c | 33 ++++++------ vp9/encoder/vp9_encodemb.c | 13 ++--- vp9/encoder/vp9_rdopt.c | 15 ++---- vp9/encoder/vp9_tokenize.c | 16 ++---- 6 files changed, 41 insertions(+), 157 deletions(-) diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index e21eaba..119624a 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c @@ -41,8 +41,12 @@ DECLARE_ALIGNED(16, const uint8_t, vp9_norm[256]) = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -DECLARE_ALIGNED(16, const int, vp9_coef_bands_4x4[16]) = { - 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7 +// Unified coefficient band structure used by all block sizes +DECLARE_ALIGNED(16, const int, vp9_coef_bands[32]) = { + 0, 1, 2, 3, 5, 4, 4, 5, + 5, 3, 6, 6, 6, 6, 6, 7, + 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7 }; DECLARE_ALIGNED(16, const uint8_t, vp9_prev_token_class[MAX_ENTROPY_TOKENS]) = { @@ -70,17 +74,6 @@ DECLARE_ALIGNED(16, const int, vp9_row_scan_4x4[16]) = { 12, 13, 14, 15 }; -DECLARE_ALIGNED(64, const int, vp9_coef_bands_8x8[64]) = { - 0, 1, 2, 3, 5, 4, 4, 5, - 5, 3, 6, 3, 5, 4, 6, 6, - 6, 5, 5, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7 -}; - DECLARE_ALIGNED(64, const int, vp9_default_zig_zag1d_8x8[64]) = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, @@ -88,26 +81,6 @@ DECLARE_ALIGNED(64, const int, vp9_default_zig_zag1d_8x8[64]) = { 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, }; -// Table can be optimized. -DECLARE_ALIGNED(16, const int, vp9_coef_bands_16x16[256]) = { - 0, 1, 2, 3, 5, 4, 4, 5, 5, 3, 6, 3, 5, 4, 6, 6, - 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -}; - DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d_16x16[256]) = { 0, 1, 16, 32, 17, 2, 3, 18, 33, 48, 64, 49, 34, 19, 4, 5, @@ -143,76 +116,6 @@ DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d_16x16[256]) = { 237, 252, 253, 238, 223, 239, 254, 255, }; -DECLARE_ALIGNED(16, const int, vp9_coef_bands_32x32[1024]) = { - 0, 1, 2, 3, 5, 4, 4, 5, 5, 3, 6, 3, 5, 4, 6, 6, - 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7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7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -}; - DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d_32x32[1024]) = { 0, 1, 32, 64, 33, 2, 3, 34, 65, 96, 128, 97, 66, 35, 4, 5, 36, 67, 98, 129, 160, 192, 161, 130, 99, 68, 37, 6, 7, 38, 69, 100, 131, 162, 193, 224, 256, 225, 194, 163, 132, 101, 70, 39, 8, 9, 40, 71, 102, 133, 164, 195, 226, 257, 288, 320, 289, 258, 227, 196, 165, 134, 103, 72, @@ -341,6 +244,13 @@ int vp9_get_coef_context(int * recent_energy, int token) { return vp9_prev_token_class[token]; }; +int vp9_get_coef_band(int coef_index) { + if (coef_index < 32) + return vp9_coef_bands[coef_index]; + else + return 7; +} + 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 1979638..4b6902e 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -72,10 +72,6 @@ extern vp9_extra_bit_struct vp9_extra_bits[12]; /* indexed by token value */ position within the 4x4 DCT. */ #define COEF_BANDS 8 -extern DECLARE_ALIGNED(16, const int, vp9_coef_bands_4x4[16]); -extern DECLARE_ALIGNED(64, const int, vp9_coef_bands_8x8[64]); -extern DECLARE_ALIGNED(16, const int, vp9_coef_bands_16x16[256]); -extern DECLARE_ALIGNED(16, const int, vp9_coef_bands_32x32[1024]); /* Inside dimension is 3-valued measure of nearby complexity, that is, the extent to which nearby coefficients are nonzero. For the first @@ -127,4 +123,5 @@ static void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) { } extern int vp9_get_coef_context(int * recent_energy, int token); +extern int vp9_get_coef_band(int coef_index); #endif // VP9_COMMON_VP9_ENTROPY_H_ diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index bfdb486..e0ad1cc 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -65,7 +65,7 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) { #define INCREMENT_COUNT(token) \ do { \ - coef_counts[type][coef_bands[c]][pt][token]++; \ + coef_counts[type][vp9_get_coef_band(c)][pt][token]++; \ pt = vp9_get_coef_context(&recent_energy, token); \ } while (0) @@ -87,8 +87,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, BOOL_DECODER* const br, int block_idx, PLANE_TYPE type, TX_TYPE tx_type, int seg_eob, int16_t *qcoeff_ptr, - const int *const scan, TX_SIZE txfm_size, - const int *coef_bands) { + const int *const scan, TX_SIZE txfm_size) { ENTROPY_CONTEXT* const A0 = (ENTROPY_CONTEXT *) xd->above_context; ENTROPY_CONTEXT* const L0 = (ENTROPY_CONTEXT *) xd->left_context; const int aidx = vp9_block2above[txfm_size][block_idx]; @@ -180,7 +179,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, 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][vp9_get_coef_band(c)][pt]; if (!vp9_read(br, prob[EOB_CONTEXT_NODE])) break; SKIP_START: @@ -188,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][vp9_get_coef_band(c)][pt]; goto SKIP_START; } // ONE_CONTEXT_NODE_0_ @@ -252,7 +251,7 @@ SKIP_START: } if (c < seg_eob) - coef_counts[type][coef_bands[c]][pt][DCT_EOB_TOKEN]++; + coef_counts[type][vp9_get_coef_band(c)][pt][DCT_EOB_TOKEN]++; A0[aidx] = L0[lidx] = (c > !type); if (txfm_size >= TX_8X8 && type != PLANE_TYPE_Y2) { @@ -312,7 +311,7 @@ int vp9_decode_sb_tokens(VP9D_COMP* const pbi, DCT_DCT, get_eob(xd, segment_id, 1024), xd->sb_coeff_data.qcoeff, vp9_default_zig_zag1d_32x32, - TX_32X32, vp9_coef_bands_32x32); + TX_32X32); eobtotal += c; // 16x16 chroma blocks @@ -321,7 +320,7 @@ int vp9_decode_sb_tokens(VP9D_COMP* const pbi, eobs[i] = c = decode_coefs(pbi, xd, bc, i, PLANE_TYPE_UV, DCT_DCT, seg_eob, xd->sb_coeff_data.qcoeff + 1024 + (i - 16) * 64, vp9_default_zig_zag1d_16x16, - TX_16X16, vp9_coef_bands_16x16); + TX_16X16); eobtotal += c; } @@ -345,7 +344,7 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi, get_tx_type(xd, &xd->block[0]), get_eob(xd, segment_id, 256), xd->qcoeff, vp9_default_zig_zag1d_16x16, - TX_16X16, vp9_coef_bands_16x16); + TX_16X16); eobtotal += c; // 8x8 chroma blocks @@ -354,7 +353,7 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi, eobs[i] = c = decode_coefs(pbi, xd, bc, i, PLANE_TYPE_UV, DCT_DCT, seg_eob, xd->block[i].qcoeff, vp9_default_zig_zag1d_8x8, - TX_8X8, vp9_coef_bands_8x8); + TX_8X8); eobtotal += c; } A[8] = 0; @@ -376,8 +375,7 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, eobs[24] = c = decode_coefs(pbi, xd, bc, 24, PLANE_TYPE_Y2, DCT_DCT, get_eob(xd, segment_id, 4), xd->block[24].qcoeff, - vp9_default_zig_zag1d_4x4, TX_8X8, - vp9_coef_bands_4x4); + vp9_default_zig_zag1d_4x4, TX_8X8); eobtotal += c - 4; type = PLANE_TYPE_Y_NO_DC; } else { @@ -394,8 +392,7 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, type == PLANE_TYPE_Y_WITH_DC ? get_tx_type(xd, xd->block + i) : DCT_DCT, seg_eob, xd->block[i].qcoeff, - vp9_default_zig_zag1d_8x8, - TX_8X8, vp9_coef_bands_8x8); + vp9_default_zig_zag1d_8x8, TX_8X8); eobtotal += c; } @@ -407,16 +404,14 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, for (i = 16; i < 24; i++) { eobs[i] = c = decode_coefs(pbi, xd, bc, i, PLANE_TYPE_UV, DCT_DCT, seg_eob, xd->block[i].qcoeff, - vp9_default_zig_zag1d_4x4, TX_4X4, - vp9_coef_bands_4x4); + vp9_default_zig_zag1d_4x4, TX_4X4); eobtotal += c; } } else { for (i = 16; i < 24; i += 4) { eobs[i] = c = decode_coefs(pbi, xd, bc, i, PLANE_TYPE_UV, DCT_DCT, seg_eob, xd->block[i].qcoeff, - vp9_default_zig_zag1d_8x8, - TX_8X8, vp9_coef_bands_8x8); + vp9_default_zig_zag1d_8x8, TX_8X8); eobtotal += c; } } @@ -432,7 +427,7 @@ static int decode_coefs_4x4(VP9D_COMP *dx, MACROBLOCKD *xd, int c; c = decode_coefs(dx, xd, bc, i, type, tx_type, seg_eob, - xd->block[i].qcoeff, scan, TX_4X4, vp9_coef_bands_4x4); + xd->block[i].qcoeff, scan, TX_4X4); eobs[i] = c; return c; diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 12082a8..459010a 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -386,13 +386,12 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, int best, band, pt; int err_mult = plane_rd_mult[type]; int default_eob; - int const *scan, *bands; + int const *scan; switch (tx_size) { default: case TX_4X4: scan = vp9_default_zig_zag1d_4x4; - bands = vp9_coef_bands_4x4; default_eob = 16; // TODO: this isn't called (for intra4x4 modes), but will be left in // since it could be used later @@ -419,12 +418,10 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, break; case TX_8X8: scan = vp9_default_zig_zag1d_8x8; - bands = vp9_coef_bands_8x8; default_eob = 64; break; case TX_16X16: scan = vp9_default_zig_zag1d_16x16; - bands = vp9_coef_bands_16x16; default_eob = 256; break; } @@ -459,7 +456,7 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, t0 = (vp9_dct_value_tokens_ptr + x)->Token; /* Consider both possible successor states. */ if (next < default_eob) { - band = bands[i + 1]; + band = vp9_get_coef_band(i + 1); pt = trellis_get_coeff_context(t0); rate0 += mb->token_costs[tx_size][type][band][pt][tokens[next][0].token]; @@ -506,7 +503,7 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, t0 = t1 = (vp9_dct_value_tokens_ptr + x)->Token; } if (next < default_eob) { - band = bands[i + 1]; + band = vp9_get_coef_band(i + 1); if (t0 != DCT_EOB_TOKEN) { pt = trellis_get_coeff_context(t0); rate0 += mb->token_costs[tx_size][type][band][pt][ @@ -541,7 +538,7 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, * add a new trellis node, but we do need to update the costs. */ else { - band = bands[i + 1]; + band = vp9_get_coef_band(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. */ @@ -558,7 +555,7 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type, } /* Now pick the best path through the whole trellis. */ - band = bands[i + 1]; + band = vp9_get_coef_band(i + 1); VP9_COMBINEENTROPYCONTEXTS(pt, *a, *l); rate0 = tokens[next][0].rate; rate1 = tokens[next][1].rate; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 8385a18..3864b89 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -431,7 +431,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0; int cost = 0, seg_eob; const int segment_id = xd->mode_info_context->mbmi.segment_id; - const int *scan, *band; + const int *scan; int16_t *qcoeff_ptr = b->qcoeff; const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type(xd, b) : DCT_DCT; @@ -443,7 +443,6 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, switch (tx_size) { case TX_4X4: scan = vp9_default_zig_zag1d_4x4; - band = vp9_coef_bands_4x4; seg_eob = 16; if (type == PLANE_TYPE_Y_WITH_DC) { if (tx_type == ADST_DCT) { @@ -456,17 +455,14 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, case TX_8X8: if (type == PLANE_TYPE_Y2) { scan = vp9_default_zig_zag1d_4x4; - band = vp9_coef_bands_4x4; seg_eob = 4; } else { scan = vp9_default_zig_zag1d_8x8; - band = vp9_coef_bands_8x8; seg_eob = 64; } break; case TX_16X16: scan = vp9_default_zig_zag1d_16x16; - band = vp9_coef_bands_16x16; seg_eob = 256; if (type == PLANE_TYPE_UV) { const int uv_idx = ib - 16; @@ -475,7 +471,6 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, break; case TX_32X32: scan = vp9_default_zig_zag1d_32x32; - band = vp9_coef_bands_32x32; seg_eob = 1024; qcoeff_ptr = xd->sb_coeff_data.qcoeff; break; @@ -494,24 +489,24 @@ 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[vp9_get_coef_band(c)][pt][t]; cost += vp9_dct_value_cost_ptr[v]; pt = vp9_get_coef_context(&recent_energy, t); } if (c < seg_eob) - cost += mb->hybrid_token_costs[tx_size][type][band[c]] + cost += mb->hybrid_token_costs[tx_size][type][vp9_get_coef_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 += token_costs[vp9_get_coef_band(c)][pt][t]; cost += vp9_dct_value_cost_ptr[v]; pt = vp9_get_coef_context(&recent_energy, t); } if (c < seg_eob) - cost += mb->token_costs[tx_size][type][band[c]] + cost += mb->token_costs[tx_size][type][vp9_get_coef_band(c)] [pt][DCT_EOB_TOKEN]; } diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 12fee90..d612eb0 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -116,7 +116,7 @@ static void tokenize_b(VP9_COMP *cpi, int16_t *qcoeff_ptr = b->qcoeff; int seg_eob; const int segment_id = xd->mode_info_context->mbmi.segment_id; - const int *bands, *scan; + const int *scan; vp9_coeff_count *counts; vp9_coeff_probs *probs; const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? @@ -138,7 +138,6 @@ static void tokenize_b(VP9_COMP *cpi, default: case TX_4X4: seg_eob = 16; - bands = vp9_coef_bands_4x4; scan = vp9_default_zig_zag1d_4x4; if (tx_type != DCT_DCT) { counts = cpi->hybrid_coef_counts_4x4; @@ -156,7 +155,6 @@ static void tokenize_b(VP9_COMP *cpi, case TX_8X8: if (type == PLANE_TYPE_Y2) { seg_eob = 4; - bands = vp9_coef_bands_4x4; scan = vp9_default_zig_zag1d_4x4; } else { #if CONFIG_CNVCONTEXT @@ -164,7 +162,6 @@ static void tokenize_b(VP9_COMP *cpi, l_ec = (l[0] + l[1]) != 0; #endif seg_eob = 64; - bands = vp9_coef_bands_8x8; scan = vp9_default_zig_zag1d_8x8; } if (tx_type != DCT_DCT) { @@ -186,7 +183,6 @@ static void tokenize_b(VP9_COMP *cpi, } #endif seg_eob = 256; - bands = vp9_coef_bands_16x16; scan = vp9_default_zig_zag1d_16x16; if (tx_type != DCT_DCT) { counts = cpi->hybrid_coef_counts_16x16; @@ -210,7 +206,6 @@ static void tokenize_b(VP9_COMP *cpi, l_ec = l_ec != 0; #endif seg_eob = 1024; - bands = vp9_coef_bands_32x32; scan = vp9_default_zig_zag1d_32x32; counts = cpi->coef_counts_32x32; probs = cpi->common.fc.coef_probs_32x32; @@ -224,7 +219,7 @@ static void tokenize_b(VP9_COMP *cpi, seg_eob = 0; do { - const int band = bands[c]; + const int band = vp9_get_coef_band(c); int token; if (c < eob) { @@ -703,7 +698,6 @@ static INLINE void stuff_b(VP9_COMP *cpi, TX_SIZE tx_size, int dry_run) { const BLOCKD * const b = xd->block + ib; - const int *bands; vp9_coeff_count *counts; vp9_coeff_probs *probs; int pt, band; @@ -723,7 +717,6 @@ static INLINE void stuff_b(VP9_COMP *cpi, switch (tx_size) { default: case TX_4X4: - bands = vp9_coef_bands_4x4; if (tx_type != DCT_DCT) { counts = cpi->hybrid_coef_counts_4x4; probs = cpi->common.fc.hybrid_coef_probs_4x4; @@ -739,7 +732,6 @@ static INLINE void stuff_b(VP9_COMP *cpi, l_ec = (l[0] + l[1]) != 0; } #endif - bands = vp9_coef_bands_8x8; if (tx_type != DCT_DCT) { counts = cpi->hybrid_coef_counts_8x8; probs = cpi->common.fc.hybrid_coef_probs_8x8; @@ -758,7 +750,6 @@ static INLINE void stuff_b(VP9_COMP *cpi, l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0; } #endif - bands = vp9_coef_bands_16x16; if (tx_type != DCT_DCT) { counts = cpi->hybrid_coef_counts_16x16; probs = cpi->common.fc.hybrid_coef_probs_16x16; @@ -776,7 +767,6 @@ static INLINE void stuff_b(VP9_COMP *cpi, a_ec = a_ec != 0; l_ec = l_ec != 0; #endif - bands = vp9_coef_bands_32x32; counts = cpi->coef_counts_32x32; probs = cpi->common.fc.coef_probs_32x32; break; @@ -784,7 +774,7 @@ static INLINE void stuff_b(VP9_COMP *cpi, VP9_COMBINEENTROPYCONTEXTS(pt, a_ec, l_ec); - band = bands[(type == PLANE_TYPE_Y_NO_DC) ? 1 : 0]; + band = vp9_get_coef_band((type == PLANE_TYPE_Y_NO_DC) ? 1 : 0); t->Token = DCT_EOB_TOKEN; t->context_tree = probs[type][band][pt]; t->skip_eob_node = 0; -- 2.7.4