summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2013-05-07 17:09:38 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-05-07 17:09:38 -0700
commitd6c490cb1546a3c12bc8f59d5c087c729e4d32fd (patch)
treefbacf148189a32cdb50a9f8f5b398aa1158a23b9 /vp9/encoder
parent9cd5406c3206beab15a01ec198ecb4f51e4a84ad (diff)
parenta14ae84749c9aa351d35811230c20253f197ddd5 (diff)
downloadlibvpx-d6c490cb1546a3c12bc8f59d5c087c729e4d32fd.tar
libvpx-d6c490cb1546a3c12bc8f59d5c087c729e4d32fd.tar.gz
libvpx-d6c490cb1546a3c12bc8f59d5c087c729e4d32fd.tar.bz2
libvpx-d6c490cb1546a3c12bc8f59d5c087c729e4d32fd.zip
Merge "Deprecate code_zerogroup experiment." into experimental
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_bitstream.c308
-rw-r--r--vp9/encoder/vp9_encodeframe.c6
-rw-r--r--vp9/encoder/vp9_onyx_if.c27
-rw-r--r--vp9/encoder/vp9_onyx_int.h6
-rw-r--r--vp9/encoder/vp9_ratectrl.c14
-rw-r--r--vp9/encoder/vp9_rdopt.c105
-rw-r--r--vp9/encoder/vp9_tokenize.c124
7 files changed, 4 insertions, 586 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 5924ceca2..a7c26a45b 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 553534ad6..8ddad26b7 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 ce911b4b8..5fdbbefe9 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -113,13 +113,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
@@ -1397,11 +1390,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;
@@ -1611,12 +1599,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;
}
@@ -1644,12 +1626,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
@@ -3234,9 +3210,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 d9325c11c..7b56f9ca7 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 09e22b119..10a3b2eab 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 21f8336a8..58abd48f3 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 9a6598581..cb670dab0 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);