From a14ae84749c9aa351d35811230c20253f197ddd5 Mon Sep 17 00:00:00 2001 From: Paul Wilkins Date: Tue, 7 May 2013 17:24:21 +0100 Subject: [PATCH] Deprecate code_zerogroup experiment. Delete code under the CONFIG_CODE_ZEROGROUP flag. Change-Id: I5fe6c7b42a5da9b73118e33594301da4129f320a --- configure | 1 - vp9/common/vp9_blockd.h | 5 - vp9/common/vp9_coefupdateprobs.h | 4 - vp9/common/vp9_default_coef_probs.h | 83 ---------- vp9/common/vp9_entropy.c | 128 --------------- vp9/common/vp9_entropy.h | 56 ------- vp9/common/vp9_onyxc_int.h | 23 --- vp9/decoder/vp9_decodframe.c | 67 +------- vp9/decoder/vp9_detokenize.c | 81 ---------- vp9/encoder/vp9_bitstream.c | 308 +----------------------------------- vp9/encoder/vp9_encodeframe.c | 6 - vp9/encoder/vp9_onyx_if.c | 27 ---- vp9/encoder/vp9_onyx_int.h | 6 - vp9/encoder/vp9_ratectrl.c | 14 -- vp9/encoder/vp9_rdopt.c | 105 +----------- vp9/encoder/vp9_tokenize.c | 124 +-------------- 16 files changed, 5 insertions(+), 1033 deletions(-) diff --git a/configure b/configure index 86bec79..5cbf070 100755 --- a/configure +++ b/configure @@ -245,7 +245,6 @@ EXPERIMENT_LIST=" scatterscan oneshotq multiple_arf - code_zerogroup non420 ab4x4 " diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index da40b3f..af8e662 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -958,9 +958,4 @@ static TX_SIZE tx_size_for_plane(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, } } -#if CONFIG_CODE_ZEROGROUP -static int get_zpc_used(TX_SIZE tx_size) { - return (tx_size >= TX_16X16); -} -#endif #endif // VP9_COMMON_VP9_BLOCKD_H_ diff --git a/vp9/common/vp9_coefupdateprobs.h b/vp9/common/vp9_coefupdateprobs.h index e49935c..231def1 100644 --- a/vp9/common/vp9_coefupdateprobs.h +++ b/vp9/common/vp9_coefupdateprobs.h @@ -18,10 +18,6 @@ static const vp9_prob vp9_coef_update_prob[ENTROPY_NODES] = { 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252 }; -#if CONFIG_CODE_ZEROGROUP -#define ZPC_UPDATE_PROB 248 -#endif - #if CONFIG_MODELCOEFPROB #define COEF_MODEL_UPDATE_PROB 16 #endif diff --git a/vp9/common/vp9_default_coef_probs.h b/vp9/common/vp9_default_coef_probs.h index 453b4a2..9e37333 100644 --- a/vp9/common/vp9_default_coef_probs.h +++ b/vp9/common/vp9_default_coef_probs.h @@ -699,86 +699,3 @@ static const vp9_coeff_probs default_coef_probs_32x32[BLOCK_TYPES] = { } } }; - -#if CONFIG_CODE_ZEROGROUP - -// There are two probs: the first is the prob(0) of the isolated zero bit, -// the second is the prob(0) of the end of orientation symbol [if 0 that -// indicates a zerotree root]. -static const vp9_zpc_probs default_zpc_probs_4x4 = { - { /* Intra */ - { /* Coeff Band 0 */ - { 1, }, { 1, }, { 1, }, - }, { /* Coeff Band 1 */ - { 1, }, { 1, }, { 1, }, - }, { /* Coeff Band 2 */ - { 1, }, { 1, }, { 1, }, - } - }, { /* Inter */ - { /* Coeff Band 0 */ - { 1, }, { 1, }, { 1, }, - }, { /* Coeff Band 1 */ - { 1, }, { 1, }, { 1, }, - }, { /* Coeff Band 2 */ - { 1, }, { 1, }, { 1, }, - } - } -}; -static const vp9_zpc_probs default_zpc_probs_8x8 = { - { /* Intra */ - { /* ZPC Band 0 */ - { 4, }, { 2, }, { 1, }, - }, { /* ZPC Band 1 */ - { 4, }, { 2, }, { 1, }, - }, { /* ZPC Band 2 */ - { 4, }, { 2, }, { 1, }, - } - }, { /* Inter */ - { /* ZPC Band 0 */ - { 4, }, { 2, }, { 1, }, - }, { /* ZPC Band 1 */ - { 4, }, { 2, }, { 1, }, - }, { /* ZPC Band 2 */ - { 4, }, { 2, }, { 1, }, - } - } -}; -static const vp9_zpc_probs default_zpc_probs_16x16 = { - { /* Intra */ - { /* ZPC Band 0 */ - { 57, }, { 30, }, { 13, }, - }, { /* ZPC Band 1 */ - { 46, }, { 23, }, { 4, }, - }, { /* ZPC Band 1 */ - { 36, }, { 11, }, { 2, }, - }, - }, { /* Inter */ - { /* ZPC Band 0 */ - { 45, }, { 21 }, { 10, }, - }, { /* ZPC Band 1 */ - { 24, }, { 14, }, { 3, }, - }, { /* ZPC Band 2 */ - { 16, }, { 6, }, { 1, }, - }, - }, -}; -static const vp9_zpc_probs default_zpc_probs_32x32 = { - { /* Intra */ - { /* ZPC Band 0 */ - { 132, }, { 60, }, { 19, }, - }, { /* ZPC Band 1 */ - { 64, }, { 32, }, { 8, }, - }, { /* ZPC Band 2 */ - { 25, }, { 11, }, { 1, }, - }, - }, { /* Inter */ - { /* ZPC Band 0 */ - { 134, }, { 39, }, { 25, }, - }, { /* ZPC Band 1 */ - { 64, }, { 24, }, { 12, }, - }, { /* ZPC Band 2 */ - { 21, }, { 10, }, { 1, }, - }, - }, -}; -#endif // CONFIG_CODE_ZEROGROUP diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index faa45bd..4dfe9c4 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c @@ -1338,16 +1338,6 @@ void vp9_default_coef_probs(VP9_COMMON *pc) { vpx_memcpy(pc->fc.coef_probs_32x32, default_coef_probs_32x32, sizeof(pc->fc.coef_probs_32x32)); #endif -#if CONFIG_CODE_ZEROGROUP - vpx_memcpy(pc->fc.zpc_probs_4x4, default_zpc_probs_4x4, - sizeof(pc->fc.zpc_probs_4x4)); - vpx_memcpy(pc->fc.zpc_probs_8x8, default_zpc_probs_8x8, - sizeof(pc->fc.zpc_probs_8x8)); - vpx_memcpy(pc->fc.zpc_probs_16x16, default_zpc_probs_16x16, - sizeof(pc->fc.zpc_probs_16x16)); - vpx_memcpy(pc->fc.zpc_probs_32x32, default_zpc_probs_32x32, - sizeof(pc->fc.zpc_probs_32x32)); -#endif } // Neighborhood 5-tuples for various scans and blocksizes, @@ -1588,121 +1578,3 @@ void vp9_adapt_coef_probs(VP9_COMMON *cm) { count_sat, update_factor); #endif } - -#if CONFIG_CODE_ZEROGROUP -OrientationType vp9_get_orientation(int rc, TX_SIZE tx_size) { - int i = rc >> (tx_size + 2); - int j = rc & ((4 << tx_size) - 1); - if (i > 2 * j) - return VERTICAL; - else if (j > 2 * i) - return HORIZONTAL; - else - return DIAGONAL; - /* - if (i == 0 && j == 0) return DIAGONAL; - while (i > 1 || j > 1) { - i >>= 1; - j >>= 1; - } - if (i == 0 && j == 1) - return HORIZONTAL; // horizontal - else if (i == 1 && j == 1) - return DIAGONAL; // diagonal - else if (i == 1 && j == 0) - return VERTICAL; // vertical - assert(0); - */ -} - -int vp9_use_eoo(int c, int seg_eob, const int *scan, - TX_SIZE tx_size, int *is_last_zero, int *is_eoo) { - // NOTE: returning 0 from this function will turn off eoo symbols - // For instance we can experiment with turning eoo off for smaller blocks - // and/or lower bands - int o = vp9_get_orientation(scan[c], tx_size); - int band = get_coef_band(scan, tx_size, c); - int use_eoo = (!is_last_zero[o] && - !is_eoo[o] && - band <= ZPC_EOO_BAND_UPPER && - band >= ZPC_EOO_BAND_LOWER && - get_zpc_used(tx_size) && - seg_eob - c > (ZPC_USEEOO_THRESH << tx_size) && - is_eoo[0] + is_eoo[1] + is_eoo[2] < 2); - return use_eoo; -} - -int vp9_is_eoo(int c, int eob, const int *scan, TX_SIZE tx_size, - const int16_t *qcoeff_ptr, int *last_nz_pos) { - int rc = scan[c]; - int o = vp9_get_orientation(rc, tx_size); - int eoo = c > last_nz_pos[o]; - return eoo; -} - -static void adapt_zpc_probs_common(VP9_COMMON *cm, - TX_SIZE tx_size, - int count_sat, - int update_factor) { - int r, b, p, n; - int count, factor; - vp9_zpc_probs *zpc_probs; - vp9_zpc_probs *pre_zpc_probs; - vp9_zpc_count *zpc_counts; - if (!get_zpc_used(tx_size)) return; - if (tx_size == TX_32X32) { - zpc_probs = &cm->fc.zpc_probs_32x32; - pre_zpc_probs = &cm->fc.pre_zpc_probs_32x32; - zpc_counts = &cm->fc.zpc_counts_32x32; - } else if (tx_size == TX_16X16) { - zpc_probs = &cm->fc.zpc_probs_16x16; - pre_zpc_probs = &cm->fc.pre_zpc_probs_16x16; - zpc_counts = &cm->fc.zpc_counts_16x16; - } else if (tx_size == TX_8X8) { - zpc_probs = &cm->fc.zpc_probs_8x8; - pre_zpc_probs = &cm->fc.pre_zpc_probs_8x8; - zpc_counts = &cm->fc.zpc_counts_8x8; - } else { - zpc_probs = &cm->fc.zpc_probs_4x4; - pre_zpc_probs = &cm->fc.pre_zpc_probs_4x4; - zpc_counts = &cm->fc.zpc_counts_4x4; - } - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob prob = get_binary_prob((*zpc_counts)[r][b][p][n][0], - (*zpc_counts)[r][b][p][n][1]); - count = (*zpc_counts)[r][b][p][n][0] + (*zpc_counts)[r][b][p][n][1]; - count = count > count_sat ? count_sat : count; - factor = (update_factor * count / count_sat); - (*zpc_probs)[r][b][p][n] = weighted_prob( - (*pre_zpc_probs)[r][b][p][n], prob, factor); - } - } - } - } -} - -// #define ZPC_COUNT_TESTING -void vp9_adapt_zpc_probs(VP9_COMMON *cm) { - int count_sat; - int update_factor; /* denominator 256 */ - - if (cm->frame_type == KEY_FRAME) { - update_factor = COEF_MAX_UPDATE_FACTOR_KEY; - count_sat = COEF_COUNT_SAT_KEY; - } else if (cm->last_frame_type == KEY_FRAME) { - update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */ - count_sat = COEF_COUNT_SAT_AFTER_KEY; - } else { - update_factor = COEF_MAX_UPDATE_FACTOR; - count_sat = COEF_COUNT_SAT; - } - - adapt_zpc_probs_common(cm, TX_4X4, count_sat, update_factor); - adapt_zpc_probs_common(cm, TX_8X8, count_sat, update_factor); - adapt_zpc_probs_common(cm, TX_16X16, count_sat, update_factor); - adapt_zpc_probs_common(cm, TX_32X32, count_sat, update_factor); -} -#endif // CONFIG_CODE_ZEROGROUP diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index f12ee95..fe3d5c6 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -176,62 +176,6 @@ void vp9_get_model_distribution(vp9_prob model, vp9_prob *tree_probs, int b, int r); #endif // CONFIG_MODELCOEFPROB -#if CONFIG_CODE_ZEROGROUP - -#define ZPC_STATS - -typedef enum { - HORIZONTAL = 0, - DIAGONAL, - VERTICAL, -} OrientationType; - -/* Note EOB should become part of this symbol eventually, - * but holding off on this for now because that is a major - * change in the rest of the codebase */ - -#define ZPC_ISOLATED (MAX_ENTROPY_TOKENS + 0) /* Isolated zero */ - -/* ZPC_EOORIENT: All remaining coefficients in the same orientation are 0. - * In other words all remaining coeffs in the current subband, and all - * children of the current subband are zero. Subbands are defined by - * dyadic partitioning in the coeff domain */ -#define ZPC_EOORIENT (MAX_ENTROPY_TOKENS + 1) /* End of Orientation */ - -/* Band limits over which the eoo bit is sent */ -#define ZPC_EOO_BAND_LOWER 0 -#define ZPC_EOO_BAND_UPPER 5 - -#define USE_ZPC_EOORIENT 1 /* 0: not used */ - /* 1: used */ -#define ZPC_NODES 1 - -#define UNKNOWN_TOKEN 255 /* Not signalled, encoder only */ - -#define ZPC_BANDS 3 /* context bands for izr */ -#define ZPC_PTOKS 3 /* context pt for zpcs */ - -#define coef_to_zpc_band(b) ((b) >> 1) -#define coef_to_zpc_ptok(p) ((p) > 2 ? 2 : (p)) - -typedef vp9_prob vp9_zpc_probs[REF_TYPES][ZPC_BANDS] - [ZPC_PTOKS][ZPC_NODES]; -typedef unsigned int vp9_zpc_count[REF_TYPES][ZPC_BANDS] - [ZPC_PTOKS][ZPC_NODES][2]; - -OrientationType vp9_get_orientation(int rc, TX_SIZE tx_size); -int vp9_use_eoo(int c, int eob, const int *scan, TX_SIZE tx_size, - int *is_last_zero, int *is_eoo); -int vp9_is_eoo(int c, int eob, const int *scan, TX_SIZE tx_size, - const int16_t *qcoeff_ptr, int *last_nz_pos); - -#define ZPC_USEEOO_THRESH 4 -#define ZPC_ZEROSSAVED_EOO 7 /* encoder only */ - -void vp9_adapt_zpc_probs(struct VP9Common *cm); - -#endif // CONFIG_CODE_ZEROGROUP - static INLINE const int* get_scan_4x4(TX_TYPE tx_type) { switch (tx_type) { case ADST_DCT: diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index f7f4c06..d9d2989 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -62,12 +62,6 @@ typedef struct frame_contexts { vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES]; vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES]; vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES]; -#if CONFIG_CODE_ZEROGROUP - vp9_zpc_probs zpc_probs_4x4; - vp9_zpc_probs zpc_probs_8x8; - vp9_zpc_probs zpc_probs_16x16; - vp9_zpc_probs zpc_probs_32x32; -#endif nmv_context nmvc; nmv_context pre_nmvc; @@ -88,12 +82,6 @@ typedef struct frame_contexts { vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES]; vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES]; vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES]; -#if CONFIG_CODE_ZEROGROUP - vp9_zpc_probs pre_zpc_probs_4x4; - vp9_zpc_probs pre_zpc_probs_8x8; - vp9_zpc_probs pre_zpc_probs_16x16; - vp9_zpc_probs pre_zpc_probs_32x32; -#endif vp9_coeff_count coef_counts_4x4[BLOCK_TYPES]; vp9_coeff_count coef_counts_8x8[BLOCK_TYPES]; @@ -102,13 +90,6 @@ typedef struct frame_contexts { unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES] [COEF_BANDS][PREV_COEF_CONTEXTS]; -#if CONFIG_CODE_ZEROGROUP - vp9_zpc_count zpc_counts_4x4; - vp9_zpc_count zpc_counts_8x8; - vp9_zpc_count zpc_counts_16x16; - vp9_zpc_count zpc_counts_32x32; -#endif - nmv_context_counts NMVcount; vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1] [VP9_SWITCHABLE_FILTERS - 1]; @@ -343,10 +324,6 @@ static int get_mi_col(const MACROBLOCKD *xd) { } static int get_token_alloc(int mb_rows, int mb_cols) { -#if CONFIG_CODE_ZEROGROUP - return mb_rows * mb_cols * (24 * 16 * 2); -#else return mb_rows * mb_cols * (24 * 16 + 4); -#endif } #endif // VP9_COMMON_VP9_ONYXC_INT_H_ diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index ea8e5af..3007863 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -530,54 +530,6 @@ static void init_frame(VP9D_COMP *pbi) { xd->mode_info_stride = pc->mode_info_stride; } -#if CONFIG_CODE_ZEROGROUP -static void read_zpc_probs_common(VP9_COMMON *cm, - vp9_reader* bc, - TX_SIZE tx_size) { - int r, b, p, n; - vp9_zpc_probs *zpc_probs; - vp9_prob upd = ZPC_UPDATE_PROB; - if (!get_zpc_used(tx_size)) return; - if (!vp9_read_bit(bc)) return; - - if (tx_size == TX_32X32) { - zpc_probs = &cm->fc.zpc_probs_32x32; - } else if (tx_size == TX_16X16) { - zpc_probs = &cm->fc.zpc_probs_16x16; - } else if (tx_size == TX_8X8) { - zpc_probs = &cm->fc.zpc_probs_8x8; - } else { - zpc_probs = &cm->fc.zpc_probs_4x4; - } - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob *q = &(*zpc_probs)[r][b][p][n]; -#if USE_ZPC_EXTRA == 0 - if (n == 1) continue; -#endif - if (vp9_read(bc, upd)) { - *q = read_prob_diff_update(bc, *q); - } - } - } - } - } -} - -static void read_zpc_probs(VP9_COMMON *cm, - vp9_reader* bc) { - read_zpc_probs_common(cm, bc, TX_4X4); - if (cm->txfm_mode > ONLY_4X4) - read_zpc_probs_common(cm, bc, TX_8X8); - if (cm->txfm_mode > ALLOW_8X8) - read_zpc_probs_common(cm, bc, TX_16X16); - if (cm->txfm_mode > ALLOW_16X16) - read_zpc_probs_common(cm, bc, TX_32X32); -} -#endif // CONFIG_CODE_ZEROGROUP - static void read_coef_probs_common(vp9_coeff_probs *coef_probs, TX_SIZE tx_size, vp9_reader *r) { @@ -855,18 +807,6 @@ static void update_frame_context(FRAME_CONTEXT *fc) { vp9_zero(fc->NMVcount); vp9_zero(fc->mv_ref_ct); vp9_zero(fc->partition_counts); - -#if CONFIG_CODE_ZEROGROUP - vp9_copy(fc->pre_zpc_probs_4x4, fc->zpc_probs_4x4); - vp9_copy(fc->pre_zpc_probs_8x8, fc->zpc_probs_8x8); - vp9_copy(fc->pre_zpc_probs_16x16, fc->zpc_probs_16x16); - vp9_copy(fc->pre_zpc_probs_32x32, fc->zpc_probs_32x32); - - vp9_zero(fc->zpc_counts_4x4); - vp9_zero(fc->zpc_counts_8x8); - vp9_zero(fc->zpc_counts_16x16); - vp9_zero(fc->zpc_counts_32x32); -#endif } static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) { @@ -1124,9 +1064,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { update_frame_context(&pc->fc); read_coef_probs(pbi, &header_bc); -#if CONFIG_CODE_ZEROGROUP - read_zpc_probs(pc, &header_bc); -#endif // Initialize xd pointers. Any reference should do for xd->pre, so use 0. setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL, @@ -1164,9 +1101,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { // Adaptation if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { vp9_adapt_coef_probs(pc); -#if CONFIG_CODE_ZEROGROUP - vp9_adapt_zpc_probs(pc); -#endif + if (pc->frame_type != KEY_FRAME) { vp9_adapt_mode_probs(pc); vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv); diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index e698441..ce2a86b 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -60,28 +60,12 @@ static const vp9_prob cat6_prob[15] = { DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); -#if CONFIG_CODE_ZEROGROUP -#define ZEROGROUP_ADVANCE() \ - do { \ - token_cache[scan[c]] = ZERO_TOKEN; \ - is_last_zero[o] = 1; \ - c++; \ - } while (0) -#define INCREMENT_COUNT(token) \ - do { \ - coef_counts[type][ref][get_coef_band(scan, txfm_size, c)] \ - [pt][token]++; \ - token_cache[scan[c]] = token; \ - is_last_zero[o] = (token == ZERO_TOKEN); \ - } while (0) -#else #define INCREMENT_COUNT(token) \ do { \ coef_counts[type][ref][get_coef_band(scan, txfm_size, c)] \ [pt][token]++; \ token_cache[scan[c]] = token; \ } while (0) -#endif #define WRITE_COEF_CONTINUE(val, token) \ { \ @@ -117,20 +101,8 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, vp9_coeff_count *coef_counts; const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME; TX_TYPE tx_type = DCT_DCT; -#if CONFIG_CODE_ZEROGROUP - int is_eoo[3] = {0, 0, 0}; - int is_last_zero[3] = {0, 0, 0}; - int o, rc; - vp9_zpc_probs *zpc_probs; - vp9_zpc_count *zpc_count; - vp9_prob *zprobs; - int eoo = 0, use_eoo; -#endif const int *scan, *nb; uint8_t token_cache[1024]; -#if CONFIG_CODE_ZEROGROUP - vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache)); -#endif switch (txfm_size) { default: @@ -143,10 +115,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &(fc->zpc_probs_4x4); - zpc_count = &(fc->zpc_counts_4x4); -#endif break; } case TX_8X8: { @@ -162,10 +130,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &(fc->zpc_probs_8x8); - zpc_count = &(fc->zpc_counts_8x8); -#endif break; } case TX_16X16: { @@ -181,10 +145,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &(fc->zpc_probs_16x16); - zpc_count = &(fc->zpc_counts_16x16); -#endif break; } case TX_32X32: @@ -194,10 +154,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &fc->zpc_probs_32x32; - zpc_count = &fc->zpc_counts_32x32; -#endif break; } @@ -218,15 +174,6 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, fc->eob_branch_counts[txfm_size][type][ref][band][pt]++; if (!vp9_read(r, prob[EOB_CONTEXT_NODE])) break; -#if CONFIG_CODE_ZEROGROUP - rc = scan[c]; - o = vp9_get_orientation(rc, txfm_size); - if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) { - coef_counts[type][ref][band][pt][ZERO_TOKEN]++; - ZEROGROUP_ADVANCE(); - goto SKIP_START; - } -#endif SKIP_START: if (c >= seg_eob) @@ -236,35 +183,7 @@ SKIP_START: c, default_eob); band = get_coef_band(scan, txfm_size, c); prob = coef_probs[type][ref][band][pt]; -#if CONFIG_CODE_ZEROGROUP - rc = scan[c]; - o = vp9_get_orientation(rc, txfm_size); - if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) { - ZEROGROUP_ADVANCE(); - goto SKIP_START; - } - zprobs = (*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)]; -#endif if (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) { -#if CONFIG_CODE_ZEROGROUP - eoo = 0; -#if USE_ZPC_EOORIENT == 1 - use_eoo = vp9_use_eoo(c, seg_eob, scan, txfm_size, is_last_zero, is_eoo); -#else - use_eoo = 0; -#endif - if (use_eoo) { - eoo = !vp9_read(r, zprobs[0]); - ++(*zpc_count)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0][!eoo]; - if (eoo) { - is_eoo[o] = 1; - } - } -#endif INCREMENT_COUNT(ZERO_TOKEN); ++c; goto SKIP_START; diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 5924cec..a7c26a4 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -50,18 +50,6 @@ vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES]; extern unsigned int active_section; #endif -#if CONFIG_CODE_ZEROGROUP -#ifdef ZPC_STATS -vp9_zpc_count zpc_stats_4x4; -vp9_zpc_count zpc_stats_8x8; -vp9_zpc_count zpc_stats_16x16; -vp9_zpc_count zpc_stats_32x32; -void init_zpcstats(); -void update_zpcstats(VP9_COMMON *const cm); -void print_zpcstats(); -#endif -#endif - #ifdef MODE_STATS int count_mb_seg[4] = { 0, 0, 0, 0 }; #endif @@ -400,20 +388,6 @@ static void pack_mb_tokens(vp9_writer* const bc, break; } assert(pp != 0); -#if CONFIG_CODE_ZEROGROUP - if (t == ZPC_ISOLATED || t == ZPC_EOORIENT) { - assert((p - 1)->token == ZERO_TOKEN); - encode_bool(bc, t == ZPC_ISOLATED, *pp); - ++p; - continue; - } else if (p->skip_coef_val) { - assert(p->skip_eob_node == 0); - assert(t == DCT_EOB_TOKEN || t == ZERO_TOKEN); - encode_bool(bc, t == ZERO_TOKEN, *pp); - ++p; - continue; - } -#endif /* skip one or two nodes */ if (p->skip_eob_node) { @@ -842,151 +816,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, } } - -#if CONFIG_CODE_ZEROGROUP -#ifdef ZPC_STATS -void init_zpcstats() { - vp9_zero(zpc_stats_4x4); - vp9_zero(zpc_stats_8x8); - vp9_zero(zpc_stats_16x16); - vp9_zero(zpc_stats_32x32); -} - -void update_zpcstats(VP9_COMMON *const cm) { - int r, b, p, n; - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - zpc_stats_4x4[r][b][p][n][0] += cm->fc.zpc_counts_4x4[r][b][p][n][0]; - zpc_stats_4x4[r][b][p][n][1] += cm->fc.zpc_counts_4x4[r][b][p][n][1]; - zpc_stats_8x8[r][b][p][n][0] += cm->fc.zpc_counts_8x8[r][b][p][n][0]; - zpc_stats_8x8[r][b][p][n][1] += cm->fc.zpc_counts_8x8[r][b][p][n][1]; - zpc_stats_16x16[r][b][p][n][0] += - cm->fc.zpc_counts_16x16[r][b][p][n][0]; - zpc_stats_16x16[r][b][p][n][1] += - cm->fc.zpc_counts_16x16[r][b][p][n][1]; - zpc_stats_32x32[r][b][p][n][0] += - cm->fc.zpc_counts_32x32[r][b][p][n][0]; - zpc_stats_32x32[r][b][p][n][1] += - cm->fc.zpc_counts_32x32[r][b][p][n][1]; - } - } - } - } -} - -void print_zpcstats() { - int r, b, p, n; - FILE *f; - - printf( - "static const unsigned int default_zpc_probs_4x4[REF_TYPES]\n" - " [ZPC_BANDS]\n" - " [ZPC_PTOKS]\n" - " [ZPC_NODES] = {\n"); - for (r = 0; r < REF_TYPES; ++r) { - printf(" {\n"); - for (b = 0; b < ZPC_BANDS; ++b) { - printf(" {\n"); - for (p = 0; p < ZPC_PTOKS; ++p) { - printf(" {"); - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob prob = get_binary_prob(zpc_stats_4x4[r][b][p][n][0], - zpc_stats_4x4[r][b][p][n][1]); - printf(" %-3d [%d/%d],", prob, zpc_stats_4x4[r][b][p][n][0], - zpc_stats_4x4[r][b][p][n][1]); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf("};\n"); - printf( - "static const unsigned int default_zpc_probs_8x8[REF_TYPES]\n" - " [ZPC_BANDS]\n" - " [ZPC_PTOKS]\n" - " [ZPC_NODES] = {\n"); - for (r = 0; r < REF_TYPES; ++r) { - printf(" {\n"); - for (b = 0; b < ZPC_BANDS; ++b) { - printf(" {\n"); - for (p = 0; p < ZPC_PTOKS; ++p) { - printf(" {"); - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob prob = get_binary_prob(zpc_stats_8x8[r][b][p][n][0], - zpc_stats_8x8[r][b][p][n][1]); - printf(" %-3d [%d/%d],", prob, zpc_stats_8x8[r][b][p][n][0], - zpc_stats_8x8[r][b][p][n][1]); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf("};\n"); - printf( - "static const unsigned int default_zpc_probs_16x16[REF_TYPES]\n" - " [ZPC_BANDS]\n" - " [ZPC_PTOKS]\n" - " [ZPC_NODES] = {\n"); - for (r = 0; r < REF_TYPES; ++r) { - printf(" {\n"); - for (b = 0; b < ZPC_BANDS; ++b) { - printf(" {\n"); - for (p = 0; p < ZPC_PTOKS; ++p) { - printf(" {"); - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob prob = get_binary_prob(zpc_stats_16x16[r][b][p][n][0], - zpc_stats_16x16[r][b][p][n][1]); - printf(" %-3d [%d/%d],", prob, zpc_stats_16x16[r][b][p][n][0], - zpc_stats_16x16[r][b][p][n][1]); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf("};\n"); - printf( - "static const unsigned int default_zpc_probs_32x32[REF_TYPES]\n" - " [ZPC_BANDS]\n" - " [ZPC_PTOKS]\n" - " [ZPC_NODES] = {\n"); - for (r = 0; r < REF_TYPES; ++r) { - printf(" {\n"); - for (b = 0; b < ZPC_BANDS; ++b) { - printf(" {\n"); - for (p = 0; p < ZPC_PTOKS; ++p) { - printf(" {"); - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob prob = get_binary_prob(zpc_stats_32x32[r][b][p][n][0], - zpc_stats_32x32[r][b][p][n][1]); - printf(" %-3d [%d/%d],", prob, zpc_stats_32x32[r][b][p][n][0], - zpc_stats_32x32[r][b][p][n][1]); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf(" },\n"); - } - printf("};\n"); - - f = fopen("zpcstats.bin", "wb"); - fwrite(zpc_stats_4x4, sizeof(zpc_stats_4x4), 1, f); - fwrite(zpc_stats_8x8, sizeof(zpc_stats_8x8), 1, f); - fwrite(zpc_stats_16x16, sizeof(zpc_stats_16x16), 1, f); - fwrite(zpc_stats_32x32, sizeof(zpc_stats_32x32), 1, f); - fclose(f); -} -#endif -#endif // CONFIG_CODE_ZEROGROUP - static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, TOKENEXTRA **tok, TOKENEXTRA *tok_end, int mi_row, int mi_col) { @@ -1223,129 +1052,6 @@ static void build_coeff_contexts(VP9_COMP *cpi) { cpi->frame_branch_ct_32x32, BLOCK_TYPES); } -#if CONFIG_CODE_ZEROGROUP -static void update_zpc_probs_common(VP9_COMP* cpi, - vp9_writer* const bc, - TX_SIZE tx_size) { - int r, b, p, n; - VP9_COMMON *const cm = &cpi->common; - int update[2] = {0, 0}; - int savings = 0; - vp9_zpc_probs newprobs; - vp9_zpc_probs *zpc_probs; - vp9_zpc_count *zpc_counts; - vp9_prob upd = ZPC_UPDATE_PROB; - - if (!get_zpc_used(tx_size)) return; - if (tx_size == TX_32X32) { - zpc_probs = &cm->fc.zpc_probs_32x32; - zpc_counts = &cm->fc.zpc_counts_32x32; - } else if (tx_size == TX_16X16) { - zpc_probs = &cm->fc.zpc_probs_16x16; - zpc_counts = &cm->fc.zpc_counts_16x16; - } else if (tx_size == TX_8X8) { - zpc_probs = &cm->fc.zpc_probs_8x8; - zpc_counts = &cm->fc.zpc_counts_8x8; - } else { - zpc_probs = &cm->fc.zpc_probs_4x4; - zpc_counts = &cm->fc.zpc_counts_4x4; - } - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - newprobs[r][b][p][n] = get_binary_prob((*zpc_counts)[r][b][p][n][0], - (*zpc_counts)[r][b][p][n][1]); - } - } - } - } - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob newp = newprobs[r][b][p][n]; - vp9_prob oldp = (*zpc_probs)[r][b][p][n]; - int s, u = 0; -#if USE_ZPC_EXTRA == 0 - if (n == 1) continue; -#endif -#if defined(SEARCH_NEWP) - s = prob_diff_update_savings_search((*zpc_counts)[r][b][p][n], - oldp, &newp, upd); - if (s > 0 && newp != oldp) - u = 1; - if (u) - savings += s - (int)(vp9_cost_zero(upd)); - else - savings -= (int)(vp9_cost_zero(upd)); -#else - s = prob_update_savings((*zpc_counts)[r][b][p][n], - oldp, newp, upd); - if (s > 0) - u = 1; - if (u) - savings += s; -#endif - update[u]++; - } - } - } - } - if (update[1] == 0 || savings < 0) { - vp9_write_bit(bc, 0); - return; - } - vp9_write_bit(bc, 1); - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < ZPC_BANDS; ++b) { - for (p = 0; p < ZPC_PTOKS; ++p) { - for (n = 0; n < ZPC_NODES; ++n) { - vp9_prob newp = newprobs[r][b][p][n]; - vp9_prob *oldp = &(*zpc_probs)[r][b][p][n]; - int s, u = 0; -#if USE_ZPC_EXTRA == 0 - if (n == 1) continue; -#endif -#if defined(SEARCH_NEWP) - s = prob_diff_update_savings_search((*zpc_counts)[r][b][p][n], - *oldp, &newp, upd); - if (s > 0 && newp != *oldp) - u = 1; -#else - s = prob_update_savings((*zpc_counts)[r][b][p][n], - *oldp, newp, upd); - if (s > 0) - u = 1; -#endif - vp9_write(bc, u, upd); - if (u) { - /* send/use new probability */ - write_prob_diff_update(bc, newp, *oldp); - *oldp = newp; - } - } - } - } - } -} - -static void update_zpc_probs(VP9_COMP* cpi, - vp9_writer* const bc) { - update_zpc_probs_common(cpi, bc, TX_4X4); - if (cpi->common.txfm_mode != ONLY_4X4) - update_zpc_probs_common(cpi, bc, TX_8X8); - if (cpi->common.txfm_mode > ALLOW_8X8) - update_zpc_probs_common(cpi, bc, TX_16X16); - if (cpi->common.txfm_mode > ALLOW_16X16) - update_zpc_probs_common(cpi, bc, TX_32X32); -#ifdef ZPC_STATS - if (!cpi->dummy_packing) - update_zpcstats(&cpi->common); -#endif -} -#endif // CONFIG_CODE_ZEROGROUP - static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi, #ifdef ENTROPY_STATS @@ -2002,16 +1708,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { cpi->common.fc.coef_probs_16x16); vp9_copy(cpi->common.fc.pre_coef_probs_32x32, cpi->common.fc.coef_probs_32x32); -#if CONFIG_CODE_ZEROGROUP - vp9_copy(cpi->common.fc.pre_zpc_probs_4x4, - cpi->common.fc.zpc_probs_4x4); - vp9_copy(cpi->common.fc.pre_zpc_probs_8x8, - cpi->common.fc.zpc_probs_8x8); - vp9_copy(cpi->common.fc.pre_zpc_probs_16x16, - cpi->common.fc.zpc_probs_16x16); - vp9_copy(cpi->common.fc.pre_zpc_probs_32x32, - cpi->common.fc.zpc_probs_32x32); -#endif + vp9_copy(cpi->common.fc.pre_sb_ymode_prob, cpi->common.fc.sb_ymode_prob); vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob); vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob); @@ -2023,9 +1720,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_zero(cpi->common.fc.mv_ref_ct); update_coef_probs(cpi, &header_bc); -#if CONFIG_CODE_ZEROGROUP - update_zpc_probs(cpi, &header_bc); -#endif #ifdef ENTROPY_STATS active_section = 2; diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 553534a..8ddad26 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1499,12 +1499,6 @@ static void encode_frame_internal(VP9_COMP *cpi) { vp9_zero(cpi->coef_counts_16x16); vp9_zero(cpi->coef_counts_32x32); vp9_zero(cm->fc.eob_branch_counts); -#if CONFIG_CODE_ZEROGROUP - vp9_zero(cm->fc.zpc_counts_4x4); - vp9_zero(cm->fc.zpc_counts_8x8); - vp9_zero(cm->fc.zpc_counts_16x16); - vp9_zero(cm->fc.zpc_counts_32x32); -#endif cpi->mb.e_mbd.lossless = (cm->base_qindex == 0 && cm->y_dc_delta_q == 0 && diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index ce407ce..67acbfd 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -114,13 +114,6 @@ extern void init_nmvstats(); extern void print_nmvstats(); #endif -#if CONFIG_CODE_ZEROGROUP -#ifdef ZPC_STATS -extern void init_zpcstats(); -extern void print_zpcstats(); -#endif -#endif - #ifdef SPEEDSTATS unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif @@ -1398,11 +1391,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) { #ifdef NMV_STATS init_nmvstats(); #endif -#if CONFIG_CODE_ZEROGROUP -#ifdef ZPC_STATS - init_zpcstats(); -#endif -#endif /*Initialize the feed-forward activity masking.*/ cpi->activity_avg = 90 << 12; @@ -1612,12 +1600,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) { cpi->common.error.setjmp = 0; vp9_zero(cpi->y_uv_mode_count) -#if CONFIG_CODE_ZEROGROUP - vp9_zero(cm->fc.zpc_counts_4x4); - vp9_zero(cm->fc.zpc_counts_8x8); - vp9_zero(cm->fc.zpc_counts_16x16); - vp9_zero(cm->fc.zpc_counts_32x32); -#endif return (VP9_PTR) cpi; } @@ -1645,12 +1627,6 @@ void vp9_remove_compressor(VP9_PTR *ptr) { if (cpi->pass != 1) print_nmvstats(); #endif -#if CONFIG_CODE_ZEROGROUP -#ifdef ZPC_STATS - if (cpi->pass != 1) - print_zpcstats(); -#endif -#endif #if CONFIG_INTERNAL_STATS @@ -3235,9 +3211,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, if (!cpi->common.error_resilient_mode && !cpi->common.frame_parallel_decoding_mode) { vp9_adapt_coef_probs(&cpi->common); -#if CONFIG_CODE_ZEROGROUP - vp9_adapt_zpc_probs(&cpi->common); -#endif } if (cpi->common.frame_type != KEY_FRAME) { diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index d9325c1..7b56f9c 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -104,12 +104,6 @@ typedef struct { int mv_ref_ct[INTER_MODE_CONTEXTS][4][2]; int vp9_mode_contexts[INTER_MODE_CONTEXTS][4]; -#if CONFIG_CODE_ZEROGROUP - vp9_zpc_probs zpc_probs_4x4; - vp9_zpc_probs zpc_probs_8x8; - vp9_zpc_probs zpc_probs_16x16; - vp9_zpc_probs zpc_probs_32x32; -#endif } CODING_CONTEXT; typedef struct { diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 09e22b1..10a3b2e 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -167,13 +167,6 @@ void vp9_save_coding_context(VP9_COMP *cpi) { vp9_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16); vp9_copy(cc->coef_probs_32x32, cm->fc.coef_probs_32x32); vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob); - -#if CONFIG_CODE_ZEROGROUP - vp9_copy(cc->zpc_probs_4x4, cm->fc.zpc_probs_4x4); - vp9_copy(cc->zpc_probs_8x8, cm->fc.zpc_probs_8x8); - vp9_copy(cc->zpc_probs_16x16, cm->fc.zpc_probs_16x16); - vp9_copy(cc->zpc_probs_32x32, cm->fc.zpc_probs_32x32); -#endif } void vp9_restore_coding_context(VP9_COMP *cpi) { @@ -225,13 +218,6 @@ void vp9_restore_coding_context(VP9_COMP *cpi) { vp9_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16); vp9_copy(cm->fc.coef_probs_32x32, cc->coef_probs_32x32); vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob); - -#if CONFIG_CODE_ZEROGROUP - vp9_copy(cm->fc.zpc_probs_4x4, cc->zpc_probs_4x4); - vp9_copy(cm->fc.zpc_probs_8x8, cc->zpc_probs_8x8); - vp9_copy(cm->fc.zpc_probs_16x16, cc->zpc_probs_16x16); - vp9_copy(cm->fc.zpc_probs_32x32, cc->zpc_probs_32x32); -#endif } void vp9_setup_key_frame(VP9_COMP *cpi) { diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 21f8336..58abd48 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -287,25 +287,12 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, ENTROPY_CONTEXT above_ec, left_ec; TX_TYPE tx_type = DCT_DCT; -#if CONFIG_CODE_ZEROGROUP - int last_nz_pos[3] = {-1, -1, -1}; // Encoder only - int is_eoo_list[3] = {0, 0, 0}; - int is_eoo_negative[3] = {0, 0, 0}; - int is_last_zero[3] = {0, 0, 0}; - int o, rc, skip_coef_val; - vp9_zpc_probs *zpc_probs; - uint8_t token_cache_full[1024]; -#endif const int segment_id = xd->mode_info_context->mbmi.segment_id; vp9_prob (*coef_probs)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] [ENTROPY_NODES]; int seg_eob, default_eob; uint8_t token_cache[1024]; -#if CONFIG_CODE_ZEROGROUP - vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache)); -#endif - // Check for consistency of tx_size with mode info assert((!type && !plane) || (type && plane)); if (type == PLANE_TYPE_Y_WITH_DC) { @@ -324,9 +311,6 @@ 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); -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &cm->fc.zpc_probs_4x4; -#endif break; } case TX_8X8: { @@ -340,9 +324,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &cm->fc.zpc_probs_8x8; -#endif break; } case TX_16X16: { @@ -356,9 +337,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &cm->fc.zpc_probs_16x16; -#endif break; } case TX_32X32: @@ -367,10 +345,6 @@ 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; - -#if CONFIG_CODE_ZEROGROUP - zpc_probs = &cm->fc.zpc_probs_32x32; -#endif break; default: abort(); @@ -389,16 +363,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, if (eob < seg_eob) assert(qcoeff_ptr[scan[eob]] == 0); -#if CONFIG_CODE_ZEROGROUP - vpx_memset(token_cache_full, ZERO_TOKEN, sizeof(token_cache_full)); - for (c = 0; c < eob; ++c) { - rc = scan[c]; - token_cache_full[rc] = vp9_dct_value_tokens_ptr[qcoeff_ptr[rc]].token; - o = vp9_get_orientation(rc, tx_size); - if (qcoeff_ptr[rc] != 0) - last_nz_pos[o] = c; - } -#endif { for (c = 0; c < eob; c++) { int v = qcoeff_ptr[scan[c]]; @@ -406,77 +370,12 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, int band = get_coef_band(scan, tx_size, c); if (c) pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob); -#if CONFIG_CODE_ZEROGROUP - rc = scan[c]; - o = vp9_get_orientation(rc, tx_size); - skip_coef_val = (token_cache[rc] == ZERO_TOKEN || is_eoo_list[o]); - if (!skip_coef_val) { - cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v]; - } else { - assert(v == 0); - } -#else + cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v]; -#endif + if (!c || token_cache[scan[c - 1]]) cost += vp9_cost_bit(coef_probs[type][ref][band][pt][0], 1); token_cache[scan[c]] = t; -#if CONFIG_CODE_ZEROGROUP - if (t == ZERO_TOKEN && !skip_coef_val) { - int eoo = 0, use_eoo; -#if USE_ZPC_EOORIENT == 1 - use_eoo = vp9_use_eoo(c, seg_eob, scan, tx_size, - is_last_zero, is_eoo_list); -#else - use_eoo = 0; -#endif - if (use_eoo) { - eoo = vp9_is_eoo(c, eob, scan, tx_size, qcoeff_ptr, last_nz_pos); - if (eoo && is_eoo_negative[o]) eoo = 0; - if (eoo) { - int c_; - int savings = 0; - int zsaved = 0; - savings = vp9_cost_bit((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0], 1) - - vp9_cost_bit((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0], 0); - for (c_ = c + 1; c_ < eob; ++c_) { - if (o == vp9_get_orientation(scan[c_], tx_size)) { - int pt_ = vp9_get_coef_context(scan, nb, pad, - token_cache_full, c_, - default_eob); - int band_ = get_coef_band(scan, tx_size, c_); - assert(token_cache_full[scan[c_]] == ZERO_TOKEN); - if (!c_ || token_cache_full[scan[c_ - 1]]) - savings += vp9_cost_bit( - coef_probs[type][ref][band_][pt_][0], 1); - savings += vp9_cost_bit( - coef_probs[type][ref][band_][pt_][1], 0); - zsaved++; - } - } - if (savings < 0) { - // if (zsaved < ZPC_ZEROSSAVED_EOO) { - eoo = 0; - is_eoo_negative[o] = 1; - } - } - } - if (use_eoo) { - cost += vp9_cost_bit((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0], !eoo); - if (eoo) { - assert(is_eoo_list[o] == 0); - is_eoo_list[o] = 1; - } - } - } - is_last_zero[o] = (t == ZERO_TOKEN); -#endif } if (c < seg_eob) { if (c) diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 9a65985..cb670da 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -136,20 +136,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - int last_nz_pos[3] = {-1, -1, -1}; // Encoder only - int is_eoo_list[3] = {0, 0, 0}; - int is_last_zero[3] = {0, 0, 0}; - int is_eoo_negative[3] = {0, 0, 0}; - int o; - vp9_zpc_probs *zpc_probs; - vp9_zpc_count *zpc_count; - uint8_t token_cache_full[1024]; -#endif -#if CONFIG_CODE_ZEROGROUP - vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache)); -#endif - assert((!type && !plane) || (type && plane)); switch (tx_size) { @@ -163,10 +149,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_count = &cpi->common.fc.zpc_counts_4x4; - zpc_probs = &cpi->common.fc.zpc_probs_4x4; -#endif break; } case TX_8X8: { @@ -180,10 +162,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_count = &cpi->common.fc.zpc_counts_8x8; - zpc_probs = &cpi->common.fc.zpc_probs_8x8; -#endif break; } case TX_16X16: { @@ -197,10 +175,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_count = &cpi->common.fc.zpc_counts_16x16; - zpc_probs = &cpi->common.fc.zpc_probs_16x16; -#endif break; } case TX_32X32: @@ -210,10 +184,6 @@ 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; -#if CONFIG_CODE_ZEROGROUP - zpc_count = &cpi->common.fc.zpc_counts_32x32; - zpc_probs = &cpi->common.fc.zpc_probs_32x32; -#endif break; } @@ -224,17 +194,6 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) seg_eob = 0; -#if CONFIG_CODE_ZEROGROUP - vpx_memset(token_cache_full, ZERO_TOKEN, sizeof(token_cache_full)); - for (c = 0; c < eob; ++c) { - rc = scan[c]; - token_cache_full[rc] = vp9_dct_value_tokens_ptr[qcoeff_ptr[rc]].token; - o = vp9_get_orientation(rc, tx_size); - if (qcoeff_ptr[rc] != 0) { - last_nz_pos[o] = c; - } - } -#endif c = 0; do { const int band = get_coef_band(scan, tx_size, c); @@ -257,94 +216,13 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, t->context_tree = coef_probs[type][ref][band][pt]; t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0); assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0); -#if CONFIG_CODE_ZEROGROUP - o = vp9_get_orientation(rc, tx_size); - t->skip_coef_val = (token_cache[rc] == ZERO_TOKEN || is_eoo_list[o]); - if (t->skip_coef_val) { - assert(v == 0); - } - // No need to transmit any token - if (t->skip_eob_node && t->skip_coef_val) { - assert(token == ZERO_TOKEN); - is_last_zero[o] = 1; - token_cache[scan[c]] = ZERO_TOKEN; - continue; - } -#endif + if (!dry_run) { ++counts[type][ref][band][pt][token]; if (!t->skip_eob_node) ++cpi->common.fc.eob_branch_counts[tx_size][type][ref][band][pt]; } token_cache[scan[c]] = token; -#if CONFIG_CODE_ZEROGROUP - if (token == ZERO_TOKEN && !t->skip_coef_val) { - int eoo = 0, use_eoo; -#if USE_ZPC_EOORIENT == 1 - use_eoo = vp9_use_eoo(c, seg_eob, scan, tx_size, - is_last_zero, is_eoo_list); -#else - use_eoo = 0; -#endif - if (use_eoo) { - eoo = vp9_is_eoo(c, eob, scan, tx_size, qcoeff_ptr, last_nz_pos); - if (eoo && is_eoo_negative[o]) eoo = 0; - if (eoo) { - int c_; - int savings = 0; - int zsaved = 0; - savings = - vp9_cost_bit((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0], 1) - - vp9_cost_bit((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0], 0); - for (c_ = c + 1; c_ < eob; ++c_) { - if (o == vp9_get_orientation(scan[c_], tx_size)) { - int pt_ = vp9_get_coef_context(scan, nb, pad, token_cache_full, - c_, default_eob); - int band_ = get_coef_band(scan, tx_size, c_); - assert(token_cache_full[scan[c_]] == ZERO_TOKEN); - if (!c_ || token_cache_full[scan[c_ - 1]]) - savings += - vp9_cost_bit(coef_probs[type][ref][band_][pt_][0], 1); - savings += vp9_cost_bit(coef_probs[type][ref][band_][pt_][1], 0); - zsaved++; - } - } - /* - if (!dry_run) - if (savings > 0) - printf("savings %d zsaved %d (%d, %d)\n", - savings, zsaved, tx_size, band); - */ - if (savings < 0) { - eoo = 0; - is_eoo_negative[o] = 1; - } - } - } - if (use_eoo) { - t++; - t->skip_eob_node = t->skip_coef_val = 0; - // transmit the eoo symbol - t->token = !eoo ? ZPC_ISOLATED : ZPC_EOORIENT; - t->context_tree = &((*zpc_probs)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0]); - if (!dry_run) - (*zpc_count)[ref] - [coef_to_zpc_band(band)] - [coef_to_zpc_ptok(pt)][0][!eoo]++; - if (eoo) { - assert(is_eoo_list[o] == 0); - is_eoo_list[o] = 1; - } - } - } - is_last_zero[o] = (token == ZERO_TOKEN); -#endif ++t; } while (c < eob && ++c < seg_eob); -- 2.7.4