summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorDeb Mukherjee <debargha@google.com>2013-04-22 10:58:49 -0700
committerDeb Mukherjee <debargha@google.com>2013-04-22 10:58:49 -0700
commit0aa79be7d52d583aab3058e9435398c4e99f3708 (patch)
treed7bcb4502ec1c5669968ba694f2e6fbe8512d826 /vp9/encoder
parent70d9f116fd90f130ec7798b16c2083c9e3853050 (diff)
downloadlibvpx-0aa79be7d52d583aab3058e9435398c4e99f3708.tar
libvpx-0aa79be7d52d583aab3058e9435398c4e99f3708.tar.gz
libvpx-0aa79be7d52d583aab3058e9435398c4e99f3708.tar.bz2
libvpx-0aa79be7d52d583aab3058e9435398c4e99f3708.zip
Removes the code_nonzerocount experiment
This patch does not seem to give any benefits. Change-Id: I9d2b4091d6af3dfc0875f24db86c01e2de57f8db
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_bitstream.c835
-rw-r--r--vp9/encoder/vp9_block.h6
-rw-r--r--vp9/encoder/vp9_encodeframe.c151
-rw-r--r--vp9/encoder/vp9_encodemb.c63
-rw-r--r--vp9/encoder/vp9_onyx_if.c27
-rw-r--r--vp9/encoder/vp9_onyx_int.h31
-rw-r--r--vp9/encoder/vp9_quantize.c51
-rw-r--r--vp9/encoder/vp9_ratectrl.c14
-rw-r--r--vp9/encoder/vp9_rdopt.c120
-rw-r--r--vp9/encoder/vp9_tokenize.c77
10 files changed, 26 insertions, 1349 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index b12e28816..952a99f64 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -50,23 +50,6 @@ vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES];
extern unsigned int active_section;
#endif
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_STATS
-unsigned int nzc_stats_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC4X4_TOKENS];
-unsigned int nzc_stats_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC8X8_TOKENS];
-unsigned int nzc_stats_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC16X16_TOKENS];
-unsigned int nzc_stats_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC32X32_TOKENS];
-unsigned int nzc_pcat_stats[MAX_NZC_CONTEXTS][NZC_TOKENS_EXTRA]
- [NZC_BITS_EXTRA][2];
-void init_nzcstats();
-void update_nzcstats(VP9_COMMON *const cm);
-void print_nzcstats();
-#endif
-#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
vp9_zpc_count zpc_stats_4x4;
@@ -1014,562 +997,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
}
}
-#if CONFIG_CODE_NONZEROCOUNT
-static void write_nzc(VP9_COMP *const cpi,
- uint16_t nzc,
- int nzc_context,
- TX_SIZE tx_size,
- int ref,
- int type,
- vp9_writer* const bc) {
- VP9_COMMON *const cm = &cpi->common;
- int c, e;
- // if (!cpi->dummy_packing && cm->current_video_frame == 27)
- // printf("nzc: %d, tx_size: %d\n", nzc, tx_size);
- if (!get_nzc_used(tx_size)) return;
- c = codenzc(nzc);
- if (tx_size == TX_32X32) {
- write_token(bc, vp9_nzc32x32_tree,
- cm->fc.nzc_probs_32x32[nzc_context][ref][type],
- vp9_nzc32x32_encodings + c);
- // cm->fc.nzc_counts_32x32[nzc_context][ref][type][c]++;
- } else if (tx_size == TX_16X16) {
- write_token(bc, vp9_nzc16x16_tree,
- cm->fc.nzc_probs_16x16[nzc_context][ref][type],
- vp9_nzc16x16_encodings + c);
- // cm->fc.nzc_counts_16x16[nzc_context][ref][type][c]++;
- } else if (tx_size == TX_8X8) {
- write_token(bc, vp9_nzc8x8_tree,
- cm->fc.nzc_probs_8x8[nzc_context][ref][type],
- vp9_nzc8x8_encodings + c);
- // cm->fc.nzc_counts_8x8[nzc_context][ref][type][c]++;
- } else if (tx_size == TX_4X4) {
- write_token(bc, vp9_nzc4x4_tree,
- cm->fc.nzc_probs_4x4[nzc_context][ref][type],
- vp9_nzc4x4_encodings + c);
- // cm->fc.nzc_counts_4x4[nzc_context][ref][type][c]++;
- } else {
- assert(0);
- }
-
- if ((e = vp9_extranzcbits[c])) {
- int x = nzc - vp9_basenzcvalue[c];
- while (e--) {
- int b = (x >> e) & 1;
- vp9_write(bc, b,
- cm->fc.nzc_pcat_probs[nzc_context][c - NZC_TOKENS_NOEXTRA][e]);
- // cm->fc.nzc_pcat_counts[nzc_context][c - NZC_TOKENS_NOEXTRA][e][b]++;
- }
- }
-}
-
-static void write_nzcs_sb64(VP9_COMP *cpi,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col,
- vp9_writer* const bc) {
- VP9_COMMON *const cm = &cpi->common;
- MODE_INFO *m = xd->mode_info_context;
- MB_MODE_INFO *const mi = &m->mbmi;
- int j, nzc_context;
- const int ref = m->mbmi.ref_frame != INTRA_FRAME;
-
- assert(mb_col == get_mb_col(xd));
- assert(mb_row == get_mb_row(xd));
-
- if (mi->mb_skip_coeff)
- return;
-
- switch (mi->txfm_size) {
- case TX_32X32:
- for (j = 0; j < 256; j += 64) {
- nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0, bc);
- }
- for (j = 256; j < 384; j += 64) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 1, bc);
- }
- break;
-
- case TX_16X16:
- for (j = 0; j < 256; j += 16) {
- nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
- }
- for (j = 256; j < 384; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
- }
- break;
-
- case TX_8X8:
- for (j = 0; j < 256; j += 4) {
- nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
- }
- for (j = 256; j < 384; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
- }
- break;
-
- case TX_4X4:
- for (j = 0; j < 256; ++j) {
- nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
- }
- for (j = 256; j < 384; ++j) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
- }
- break;
-
- default:
- break;
- }
-}
-
-static void write_nzcs_sb32(VP9_COMP *cpi,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col,
- vp9_writer* const bc) {
- VP9_COMMON *const cm = &cpi->common;
- MODE_INFO *m = xd->mode_info_context;
- MB_MODE_INFO *const mi = &m->mbmi;
- int j, nzc_context;
- const int ref = m->mbmi.ref_frame != INTRA_FRAME;
-
- assert(mb_col == get_mb_col(xd));
- assert(mb_row == get_mb_row(xd));
-
- if (mi->mb_skip_coeff)
- return;
-
- switch (mi->txfm_size) {
- case TX_32X32:
- for (j = 0; j < 64; j += 64) {
- nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0, bc);
- }
- for (j = 64; j < 96; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
- }
- break;
-
- case TX_16X16:
- for (j = 0; j < 64; j += 16) {
- nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
- }
- for (j = 64; j < 96; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
- }
- break;
-
- case TX_8X8:
- for (j = 0; j < 64; j += 4) {
- nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
- }
- for (j = 64; j < 96; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
- }
- break;
-
- case TX_4X4:
- for (j = 0; j < 64; ++j) {
- nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
- }
- for (j = 64; j < 96; ++j) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
- }
- break;
-
- default:
- break;
- }
-}
-
-static void write_nzcs_mb16(VP9_COMP *cpi,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col,
- vp9_writer* const bc) {
- VP9_COMMON *const cm = &cpi->common;
- MODE_INFO *m = xd->mode_info_context;
- MB_MODE_INFO *const mi = &m->mbmi;
- int j, nzc_context;
- const int ref = m->mbmi.ref_frame != INTRA_FRAME;
-
- assert(mb_col == get_mb_col(xd));
- assert(mb_row == get_mb_row(xd));
-
- if (mi->mb_skip_coeff)
- return;
-
- switch (mi->txfm_size) {
- case TX_16X16:
- for (j = 0; j < 16; j += 16) {
- nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
- }
- for (j = 16; j < 24; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
- }
- break;
-
- case TX_8X8:
- for (j = 0; j < 16; j += 4) {
- nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
- }
- if (mi->mode == I8X8_PRED || mi->mode == SPLITMV) {
- for (j = 16; j < 24; ++j) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
- }
- } else {
- for (j = 16; j < 24; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
- }
- }
- break;
-
- case TX_4X4:
- for (j = 0; j < 16; ++j) {
- nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
- }
- for (j = 16; j < 24; ++j) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
- }
- break;
-
- default:
- break;
- }
-}
-
-#ifdef NZC_STATS
-void init_nzcstats() {
- vp9_zero(nzc_stats_4x4);
- vp9_zero(nzc_stats_8x8);
- vp9_zero(nzc_stats_16x16);
- vp9_zero(nzc_stats_32x32);
- vp9_zero(nzc_pcat_stats);
-}
-
-void update_nzcstats(VP9_COMMON *const cm) {
- int c, r, b, t;
-
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- for (t = 0; t < NZC4X4_TOKENS; ++t) {
- nzc_stats_4x4[c][r][b][t] += cm->fc.nzc_counts_4x4[c][r][b][t];
- }
- }
- }
- }
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- for (t = 0; t < NZC8X8_TOKENS; ++t) {
- nzc_stats_8x8[c][r][b][t] += cm->fc.nzc_counts_8x8[c][r][b][t];
- }
- }
- }
- }
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- for (t = 0; t < NZC16X16_TOKENS; ++t) {
- nzc_stats_16x16[c][r][b][t] += cm->fc.nzc_counts_16x16[c][r][b][t];
- }
- }
- }
- }
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- for (t = 0; t < NZC32X32_TOKENS; ++t) {
- nzc_stats_32x32[c][r][b][t] += cm->fc.nzc_counts_32x32[c][r][b][t];
- }
- }
- }
- }
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
- int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
- for (b = 0; b < bits; ++b) {
- nzc_pcat_stats[c][t][b][0] += cm->fc.nzc_pcat_counts[c][t][b][0];
- nzc_pcat_stats[c][t][b][1] += cm->fc.nzc_pcat_counts[c][t][b][1];
- }
- }
- }
-}
-
-void print_nzcstats() {
- int c, r, b, t;
- FILE *f;
-
- printf(
- "static const unsigned int default_nzc_counts_4x4[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC4X4_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- printf(" {");
- for (t = 0; t < NZC4X4_TOKENS; ++t) {
- printf(" %-3d,", nzc_stats_4x4[c][r][b][t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const unsigned int default_nzc_counts_8x8[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC8X8_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- printf(" {");
- for (t = 0; t < NZC8X8_TOKENS; ++t) {
- printf(" %-3d,", nzc_stats_8x8[c][r][b][t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const unsigned int default_nzc_counts_16x16[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC16X16_TOKENS] = {"
- "\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- printf(" {");
- for (t = 0; t < NZC16X16_TOKENS; ++t) {
- printf(" %-3d,", nzc_stats_16x16[c][r][b][t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const unsigned int default_nzc_counts_32x32[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC32X32_TOKENS] = {"
- "\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- printf(" {");
- for (t = 0; t < NZC32X32_TOKENS; ++t) {
- printf(" %-3d,", nzc_stats_32x32[c][r][b][t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_pcat_counts[MAX_NZC_CONTEXTS]\n"
- " [NZC_TOKENS_EXTRA]\n"
- " [NZC_BITS_EXTRA] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
- printf(" {");
- for (b = 0; b < NZC_BITS_EXTRA; ++b) {
- printf(" %d/%d,",
- nzc_pcat_stats[c][t][b][0], nzc_pcat_stats[c][t][b][1]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_probs_4x4[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC4X4_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- vp9_prob probs[NZC4X4_NODES];
- unsigned int branch_ct[NZC4X4_NODES][2];
- vp9_tree_probs_from_distribution(vp9_nzc4x4_tree,
- probs, branch_ct,
- nzc_stats_4x4[c][r][b], 0);
- printf(" {");
- for (t = 0; t < NZC4X4_NODES; ++t) {
- printf(" %-3d,", probs[t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_probs_8x8[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC8X8_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- vp9_prob probs[NZC8X8_NODES];
- unsigned int branch_ct[NZC8X8_NODES][2];
- vp9_tree_probs_from_distribution(vp9_nzc8x8_tree,
- probs, branch_ct,
- nzc_stats_8x8[c][r][b], 0);
- printf(" {");
- for (t = 0; t < NZC8X8_NODES; ++t) {
- printf(" %-3d,", probs[t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_probs_16x16[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC16X16_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- vp9_prob probs[NZC16X16_NODES];
- unsigned int branch_ct[NZC16X16_NODES][2];
- vp9_tree_probs_from_distribution(vp9_nzc16x16_tree,
- probs, branch_ct,
- nzc_stats_16x16[c][r][b], 0);
- printf(" {");
- for (t = 0; t < NZC16X16_NODES; ++t) {
- printf(" %-3d,", probs[t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_probs_32x32[MAX_NZC_CONTEXTS]\n"
- " [REF_TYPES]\n"
- " [BLOCK_TYPES]\n"
- " [NZC32X32_TOKENS] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf(" {\n");
- for (b = 0; b < BLOCK_TYPES; ++b) {
- vp9_prob probs[NZC32X32_NODES];
- unsigned int branch_ct[NZC32X32_NODES][2];
- vp9_tree_probs_from_distribution(vp9_nzc32x32_tree,
- probs, branch_ct,
- nzc_stats_32x32[c][r][b], 0);
- printf(" {");
- for (t = 0; t < NZC32X32_NODES; ++t) {
- printf(" %-3d,", probs[t]);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- printf(
- "static const vp9_prob default_nzc_pcat_probs[MAX_NZC_CONTEXTS]\n"
- " [NZC_TOKENS_EXTRA]\n"
- " [NZC_BITS_EXTRA] = {\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- printf(" {\n");
- for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
- printf(" {");
- for (b = 0; b < NZC_BITS_EXTRA; ++b) {
- vp9_prob prob = get_binary_prob(nzc_pcat_stats[c][t][b][0],
- nzc_pcat_stats[c][t][b][1]);
- printf(" %-3d,", prob);
- }
- printf(" },\n");
- }
- printf(" },\n");
- }
- printf("};\n");
-
- f = fopen("nzcstats.bin", "wb");
- fwrite(nzc_stats_4x4, sizeof(nzc_stats_4x4), 1, f);
- fwrite(nzc_stats_8x8, sizeof(nzc_stats_8x8), 1, f);
- fwrite(nzc_stats_16x16, sizeof(nzc_stats_16x16), 1, f);
- fwrite(nzc_stats_32x32, sizeof(nzc_stats_32x32), 1, f);
- fwrite(nzc_pcat_stats, sizeof(nzc_pcat_stats), 1, f);
- fclose(f);
-}
-#endif
-
-#endif // CONFIG_CODE_NONZEROCOUNT
-
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
void init_zpcstats() {
@@ -1736,14 +1163,6 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
active_section = 1;
#endif
}
-#if CONFIG_CODE_NONZEROCOUNT
- if (m->mbmi.sb_type == BLOCK_SIZE_SB64X64)
- write_nzcs_sb64(cpi, xd, mb_row, mb_col, bc);
- else if (m->mbmi.sb_type == BLOCK_SIZE_SB32X32)
- write_nzcs_sb32(cpi, xd, mb_row, mb_col, bc);
- else
- write_nzcs_mb16(cpi, xd, mb_row, mb_col, bc);
-#endif
assert(*tok < tok_end);
pack_mb_tokens(bc, tok, tok_end);
@@ -2075,232 +1494,6 @@ static void update_zpc_probs(VP9_COMP* cpi,
}
#endif // CONFIG_CODE_ZEROGROUP
-#if CONFIG_CODE_NONZEROCOUNT
-static void update_nzc_probs_common(VP9_COMP* cpi,
- vp9_writer* const bc,
- TX_SIZE tx_size) {
- VP9_COMMON *cm = &cpi->common;
- int c, r, b, t;
- int update[2] = {0, 0};
- int savings = 0;
- int tokens, nodes;
- const vp9_tree_index *nzc_tree;
- vp9_prob *new_nzc_probs;
- vp9_prob *old_nzc_probs;
- unsigned int *nzc_counts;
- unsigned int (*nzc_branch_ct)[2];
- vp9_prob upd;
-
- if (!get_nzc_used(tx_size)) return;
- if (tx_size == TX_32X32) {
- tokens = NZC32X32_TOKENS;
- nzc_tree = vp9_nzc32x32_tree;
- old_nzc_probs = cm->fc.nzc_probs_32x32[0][0][0];
- new_nzc_probs = cpi->frame_nzc_probs_32x32[0][0][0];
- nzc_counts = cm->fc.nzc_counts_32x32[0][0][0];
- nzc_branch_ct = cpi->frame_nzc_branch_ct_32x32[0][0][0];
- upd = NZC_UPDATE_PROB_32X32;
- } else if (tx_size == TX_16X16) {
- tokens = NZC16X16_TOKENS;
- nzc_tree = vp9_nzc16x16_tree;
- old_nzc_probs = cm->fc.nzc_probs_16x16[0][0][0];
- new_nzc_probs = cpi->frame_nzc_probs_16x16[0][0][0];
- nzc_counts = cm->fc.nzc_counts_16x16[0][0][0];
- nzc_branch_ct = cpi->frame_nzc_branch_ct_16x16[0][0][0];
- upd = NZC_UPDATE_PROB_16X16;
- } else if (tx_size == TX_8X8) {
- tokens = NZC8X8_TOKENS;
- nzc_tree = vp9_nzc8x8_tree;
- old_nzc_probs = cm->fc.nzc_probs_8x8[0][0][0];
- new_nzc_probs = cpi->frame_nzc_probs_8x8[0][0][0];
- nzc_counts = cm->fc.nzc_counts_8x8[0][0][0];
- nzc_branch_ct = cpi->frame_nzc_branch_ct_8x8[0][0][0];
- upd = NZC_UPDATE_PROB_8X8;
- } else {
- nzc_tree = vp9_nzc4x4_tree;
- tokens = NZC4X4_TOKENS;
- old_nzc_probs = cm->fc.nzc_probs_4x4[0][0][0];
- new_nzc_probs = cpi->frame_nzc_probs_4x4[0][0][0];
- nzc_counts = cm->fc.nzc_counts_4x4[0][0][0];
- nzc_branch_ct = cpi->frame_nzc_branch_ct_4x4[0][0][0];
- upd = NZC_UPDATE_PROB_4X4;
- }
- nodes = tokens - 1;
- // Get the new probabilities and the branch counts
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
- int offset_nodes = offset * nodes;
- int offset_tokens = offset * tokens;
- vp9_tree_probs_from_distribution(nzc_tree,
- new_nzc_probs + offset_nodes,
- nzc_branch_ct + offset_nodes,
- nzc_counts + offset_tokens, 0);
- }
- }
- }
-
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
- int offset_nodes = offset * nodes;
- for (t = 0; t < nodes; ++t) {
- vp9_prob newp = new_nzc_probs[offset_nodes + t];
- vp9_prob oldp = old_nzc_probs[offset_nodes + t];
- int s, u = 0;
-#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(nzc_branch_ct[offset_nodes],
- 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(nzc_branch_ct[offset_nodes],
- 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);
- } else {
- vp9_write_bit(bc, 1);
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
- int offset_nodes = offset * nodes;
- for (t = 0; t < nodes; ++t) {
- vp9_prob newp = new_nzc_probs[offset_nodes + t];
- vp9_prob *oldp = &old_nzc_probs[offset_nodes + t];
- int s, u = 0;
-#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(nzc_branch_ct[offset_nodes],
- *oldp, &newp, upd);
- if (s > 0 && newp != *oldp)
- u = 1;
-#else
- s = prob_update_savings(nzc_branch_ct[offset_nodes],
- *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_nzc_pcat_probs(VP9_COMP *cpi, vp9_writer* const bc) {
- VP9_COMMON *cm = &cpi->common;
- int c, t, b;
- int update[2] = {0, 0};
- int savings = 0;
- vp9_prob upd = NZC_UPDATE_PROB_PCAT;
- if (!(get_nzc_used(TX_4X4) || get_nzc_used(TX_8X8) ||
- get_nzc_used(TX_16X16) || get_nzc_used(TX_32X32)))
- return;
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
- int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
- for (b = 0; b < bits; ++b) {
- vp9_prob newp = get_binary_prob(cm->fc.nzc_pcat_counts[c][t][b][0],
- cm->fc.nzc_pcat_counts[c][t][b][1]);
- vp9_prob oldp = cm->fc.nzc_pcat_probs[c][t][b];
- int s, u = 0;
-#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(cm->fc.nzc_pcat_counts[c][t][b],
- 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(cm->fc.nzc_pcat_counts[c][t][b],
- 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);
- } else {
- vp9_write_bit(bc, 1);
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
- for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
- int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
- for (b = 0; b < bits; ++b) {
- vp9_prob newp = get_binary_prob(cm->fc.nzc_pcat_counts[c][t][b][0],
- cm->fc.nzc_pcat_counts[c][t][b][1]);
- vp9_prob *oldp = &cm->fc.nzc_pcat_probs[c][t][b];
- int s, u = 0;
-#if defined(SEARCH_NEWP)
- s = prob_diff_update_savings_search(cm->fc.nzc_pcat_counts[c][t][b],
- *oldp, &newp, upd);
- if (s > 0 && newp != *oldp)
- u = 1;
-#else
- s = prob_update_savings(cm->fc.nzc_pcat_counts[c][t][b],
- *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_nzc_probs(VP9_COMP* cpi,
- vp9_writer* const bc) {
- update_nzc_probs_common(cpi, bc, TX_4X4);
- if (cpi->common.txfm_mode != ONLY_4X4)
- update_nzc_probs_common(cpi, bc, TX_8X8);
- if (cpi->common.txfm_mode > ALLOW_8X8)
- update_nzc_probs_common(cpi, bc, TX_16X16);
- if (cpi->common.txfm_mode > ALLOW_16X16)
- update_nzc_probs_common(cpi, bc, TX_32X32);
-#ifdef NZC_PCAT_UPDATE
- update_nzc_pcat_probs(cpi, bc);
-#endif
-#ifdef NZC_STATS
- if (!cpi->dummy_packing)
- update_nzcstats(&cpi->common);
-#endif
-}
-#endif // CONFIG_CODE_NONZEROCOUNT
-
static void update_coef_probs_common(vp9_writer* const bc,
VP9_COMP *cpi,
#ifdef ENTROPY_STATS
@@ -2320,11 +1513,7 @@ static void update_coef_probs_common(vp9_writer* const bc,
#endif
// vp9_prob bestupd = find_coef_update_prob(cpi);
-#if CONFIG_CODE_NONZEROCOUNT
- const int tstart = get_nzc_used(tx_size);
-#else
const int tstart = 0;
-#endif
/* dry run to see if there is any udpate at all needed */
savings = 0;
for (i = 0; i < BLOCK_TYPES; ++i) {
@@ -2966,27 +2155,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
cpi->common.fc.coef_probs_16x16);
vp9_copy(cpi->common.fc.pre_coef_probs_32x32,
cpi->common.fc.coef_probs_32x32);
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_copy(cpi->common.fc.pre_nzc_probs_4x4,
- cpi->common.fc.nzc_probs_4x4);
- vp9_copy(cpi->common.fc.pre_nzc_probs_8x8,
- cpi->common.fc.nzc_probs_8x8);
- vp9_copy(cpi->common.fc.pre_nzc_probs_16x16,
- cpi->common.fc.nzc_probs_16x16);
- vp9_copy(cpi->common.fc.pre_nzc_probs_32x32,
- cpi->common.fc.nzc_probs_32x32);
- vp9_copy(cpi->common.fc.pre_nzc_pcat_probs,
- cpi->common.fc.nzc_pcat_probs);
- // NOTE that if the counts are reset, we also need to uncomment
- // the count updates in the write_nzc function
- /*
- vp9_zero(cpi->common.fc.nzc_counts_4x4);
- vp9_zero(cpi->common.fc.nzc_counts_8x8);
- vp9_zero(cpi->common.fc.nzc_counts_16x16);
- vp9_zero(cpi->common.fc.nzc_counts_32x32);
- vp9_zero(cpi->common.fc.nzc_pcat_counts);
- */
-#endif
#if CONFIG_CODE_ZEROGROUP
vp9_copy(cpi->common.fc.pre_zpc_probs_4x4,
cpi->common.fc.zpc_probs_4x4);
@@ -3014,9 +2182,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_zero(cpi->common.fc.mv_ref_ct);
update_coef_probs(cpi, &header_bc);
-#if CONFIG_CODE_NONZEROCOUNT
- update_nzc_probs(cpi, &header_bc);
-#endif
#if CONFIG_CODE_ZEROGROUP
update_zpc_probs(cpi, &header_bc);
#endif
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index f4e3c2eab..e511be8cd 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -151,12 +151,6 @@ struct macroblock {
unsigned char *active_ptr;
vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES];
-#if CONFIG_CODE_NONZEROCOUNT
- unsigned int nzc_costs_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][17];
- unsigned int nzc_costs_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][65];
- unsigned int nzc_costs_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][257];
- unsigned int nzc_costs_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][1025];
-#endif
int optimize;
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index dbd06a06c..e3ff4ad33 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -738,9 +738,6 @@ static void update_stats(VP9_COMP *cpi, int mb_row, int mb_col) {
if ((mbmi->mode == ZEROMV) && (mbmi->ref_frame == LAST_FRAME))
cpi->inter_zz_count++;
}
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_update_nzc_counts(&cpi->common, xd, mb_row, mb_col);
-#endif
}
static void encode_sb(VP9_COMP *cpi,
@@ -1338,13 +1335,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_NONZEROCOUNT
- vp9_zero(cm->fc.nzc_counts_4x4);
- vp9_zero(cm->fc.nzc_counts_8x8);
- vp9_zero(cm->fc.nzc_counts_16x16);
- vp9_zero(cm->fc.nzc_counts_32x32);
- vp9_zero(cm->fc.nzc_pcat_counts);
-#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zero(cm->fc.zpc_counts_4x4);
vp9_zero(cm->fc.zpc_counts_8x8);
@@ -1881,137 +1871,6 @@ static void adjust_act_zbin(VP9_COMP *cpi, MACROBLOCK *x) {
#endif
}
-#if CONFIG_CODE_NONZEROCOUNT
-static void gather_nzcs_mb16(VP9_COMMON *const cm,
- MACROBLOCKD *xd) {
- int i;
- vpx_memset(xd->mode_info_context->mbmi.nzcs, 0,
- 384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
- switch (xd->mode_info_context->mbmi.txfm_size) {
- case TX_4X4:
- for (i = 0; i < 24; ++i) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_8X8:
- for (i = 0; i < 16; i += 4) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- if (xd->mode_info_context->mbmi.mode == I8X8_PRED ||
- xd->mode_info_context->mbmi.mode == SPLITMV) {
- for (i = 16; i < 24; ++i) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- } else {
- for (i = 16; i < 24; i += 4) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- }
- break;
-
- case TX_16X16:
- xd->mode_info_context->mbmi.nzcs[0] = xd->nzcs[0];
- for (i = 16; i < 24; i += 4) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- default:
- break;
- }
-}
-
-static void gather_nzcs_sb32(VP9_COMMON *const cm,
- MACROBLOCKD *xd) {
- MODE_INFO *m = xd->mode_info_context;
- int mis = cm->mode_info_stride;
- int i, j;
-
- vpx_memset(m->mbmi.nzcs, 0,
- 384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
- switch (xd->mode_info_context->mbmi.txfm_size) {
- case TX_4X4:
- for (i = 0; i < 96; ++i) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_8X8:
- for (i = 0; i < 96; i += 4) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_16X16:
- for (i = 0; i < 96; i += 16) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_32X32:
- xd->mode_info_context->mbmi.nzcs[0] = xd->nzcs[0];
- for (i = 64; i < 96; i += 16) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- default:
- break;
- }
- for (i = 0; i < 2; ++i)
- for (j = 0; j < 2; ++j) {
- if (i == 0 && j == 0) continue;
- vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
- 384 * sizeof(m->mbmi.nzcs[0]));
- }
-}
-
-static void gather_nzcs_sb64(VP9_COMMON *const cm,
- MACROBLOCKD *xd) {
- MODE_INFO *m = xd->mode_info_context;
- int mis = cm->mode_info_stride;
- int i, j;
-
- vpx_memset(xd->mode_info_context->mbmi.nzcs, 0,
- 384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
- switch (xd->mode_info_context->mbmi.txfm_size) {
- case TX_4X4:
- for (i = 0; i < 384; ++i) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_8X8:
- for (i = 0; i < 384; i += 4) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_16X16:
- for (i = 0; i < 384; i += 16) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- case TX_32X32:
- for (i = 0; i < 384; i += 64) {
- xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
- }
- break;
-
- default:
- break;
- }
- for (i = 0; i < 4; ++i)
- for (j = 0; j < 4; ++j) {
- if (i == 0 && j == 0) continue;
- vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
- 384 * sizeof(m->mbmi.nzcs[0]));
- }
-}
-#endif
-
static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
int output_enabled,
int mb_row, int mb_col) {
@@ -2197,9 +2056,6 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
}
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- gather_nzcs_mb16(cm, xd);
-#endif
vp9_tokenize_mb(cpi, xd, t, !output_enabled);
} else {
@@ -2419,13 +2275,6 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
default: assert(0);
}
vp9_recon_sb_c(xd, bsize);
-#if CONFIG_CODE_NONZEROCOUNT
- if (bsize == BLOCK_SIZE_SB32X32) {
- gather_nzcs_sb32(cm, &x->e_mbd);
- } else {
- gather_nzcs_sb64(cm, &x->e_mbd);
- }
-#endif
vp9_tokenize_sb(cpi, &x->e_mbd, t, !output_enabled, bsize);
} else {
// FIXME(rbultje): not tile-aware (mi - 1)
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index cf2625db4..da49feee1 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -326,24 +326,6 @@ static void optimize_b(VP9_COMMON *const cm,
int const *scan, *nb;
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
-#if CONFIG_CODE_NONZEROCOUNT
- // TODO(debargha): the dynamic programming approach used in this function
- // is not compatible with the true rate cost when nzcs are used. Note
- // the total rate is the sum of the nzc rate and the indicvidual token
- // rates. The latter part can be optimized in this function, but because
- // the nzc rate is a function of all the other tokens without a Markov
- // relationship this rate cannot be considered correctly.
- // The current implementation uses a suboptimal approach to account for
- // the nzc rates somewhat, but in reality the optimization approach needs
- // to change substantially.
- const int nzc_used = get_nzc_used(tx_size);
- uint16_t nzc = xd->nzcs[ib];
- uint16_t nzc0, nzc1;
- uint16_t final_nzc = 0, final_nzc_exp;
- int nzc_context = vp9_get_nzc_context(cm, xd, ib);
- unsigned int *nzc_cost;
- nzc0 = nzc1 = nzc;
-#endif
assert((!type && !pb_idx.plane) || (type && pb_idx.plane));
dqcoeff_ptr = BLOCK_OFFSET(xd->plane[pb_idx.plane].dqcoeff, pb_idx.block, 16);
@@ -353,9 +335,6 @@ static void optimize_b(VP9_COMMON *const cm,
case TX_4X4: {
const TX_TYPE tx_type = get_tx_type_4x4(xd, ib);
default_eob = 16;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_4x4[nzc_context][ref][type];
-#endif
if (tx_type == DCT_ADST) {
scan = vp9_col_scan_4x4;
} else if (tx_type == ADST_DCT) {
@@ -378,9 +357,6 @@ static void optimize_b(VP9_COMMON *const cm,
scan = vp9_default_zig_zag1d_8x8;
}
default_eob = 64;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_8x8[nzc_context][ref][type];
-#endif
break;
}
case TX_16X16: {
@@ -396,17 +372,11 @@ static void optimize_b(VP9_COMMON *const cm,
scan = vp9_default_zig_zag1d_16x16;
}
default_eob = 256;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_16x16[nzc_context][ref][type];
-#endif
break;
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
default_eob = 1024;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_32x32[nzc_context][ref][type];
-#endif
break;
}
assert(eob <= default_eob);
@@ -418,11 +388,7 @@ static void optimize_b(VP9_COMMON *const cm,
rddiv = mb->rddiv;
memset(best_index, 0, sizeof(best_index));
/* Initialize the sentinel node of the trellis. */
-#if CONFIG_CODE_NONZEROCOUNT
- tokens[eob][0].rate = nzc_used ? nzc_cost[nzc] : 0;
-#else
tokens[eob][0].rate = 0;
-#endif
tokens[eob][0].error = 0;
tokens[eob][0].next = default_eob;
tokens[eob][0].token = DCT_EOB_TOKEN;
@@ -435,9 +401,6 @@ static void optimize_b(VP9_COMMON *const cm,
for (i = eob; i-- > i0;) {
int base_bits, d2, dx;
-#if CONFIG_CODE_NONZEROCOUNT
- int new_nzc0, new_nzc1;
-#endif
rc = scan[i];
x = qcoeff_ptr[rc];
@@ -472,9 +435,6 @@ static void optimize_b(VP9_COMMON *const cm,
tokens[i][0].token = t0;
tokens[i][0].qc = x;
best_index[i][0] = best;
-#if CONFIG_CODE_NONZEROCOUNT
- new_nzc0 = (best ? nzc1 : nzc0);
-#endif
/* Evaluate the second possibility for this state. */
rate0 = tokens[next][0].rate;
@@ -501,14 +461,6 @@ static void optimize_b(VP9_COMMON *const cm,
DCT_EOB_TOKEN : ZERO_TOKEN;
t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
DCT_EOB_TOKEN : ZERO_TOKEN;
-#if CONFIG_CODE_NONZEROCOUNT
- // Account for rate drop because of the nzc change.
- // TODO(debargha): Find a better solution
- if (nzc_used) {
- rate0 -= nzc_cost[nzc0] - nzc_cost[nzc0 - 1];
- rate1 -= nzc_cost[nzc1] - nzc_cost[nzc1 - 1];
- }
-#endif
} else {
t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token;
}
@@ -543,11 +495,6 @@ static void optimize_b(VP9_COMMON *const cm,
tokens[i][1].token = best ? t1 : t0;
tokens[i][1].qc = x;
best_index[i][1] = best;
-#if CONFIG_CODE_NONZEROCOUNT
- new_nzc1 = (best ? nzc1 : nzc0) - (!x);
- nzc0 = new_nzc0;
- nzc1 = new_nzc1;
-#endif
/* Finally, make this the new head of the trellis. */
next = i;
}
@@ -586,9 +533,6 @@ static void optimize_b(VP9_COMMON *const cm,
rate1 += mb->token_costs[tx_size][type][ref][band][pt][t1];
UPDATE_RD_COST();
best = rd_cost1 < rd_cost0;
-#if CONFIG_CODE_NONZEROCOUNT
- final_nzc_exp = (best ? nzc1 : nzc0);
-#endif
final_eob = i0 - 1;
vpx_memset(qcoeff_ptr, 0, sizeof(*qcoeff_ptr) * (16 << (tx_size * 2)));
vpx_memset(dqcoeff_ptr, 0, sizeof(*dqcoeff_ptr) * (16 << (tx_size * 2)));
@@ -596,9 +540,6 @@ static void optimize_b(VP9_COMMON *const cm,
x = tokens[i][best].qc;
if (x) {
final_eob = i;
-#if CONFIG_CODE_NONZEROCOUNT
- ++final_nzc;
-#endif
}
rc = scan[i];
qcoeff_ptr[rc] = x;
@@ -611,10 +552,6 @@ static void optimize_b(VP9_COMMON *const cm,
xd->plane[pb_idx.plane].eobs[pb_idx.block] = final_eob;
*a = *l = (final_eob > 0);
-#if CONFIG_CODE_NONZEROCOUNT
- assert(final_nzc == final_nzc_exp);
- xd->nzcs[ib] = final_nzc;
-#endif
}
void vp9_optimize_sby_32x32(VP9_COMMON *const cm, MACROBLOCK *x,
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 1c308af39..b29487013 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -114,12 +114,6 @@ extern void init_nmvstats();
extern void print_nmvstats();
#endif
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_STATS
-extern void init_nzcstats();
-extern void print_nzcstats();
-#endif
-#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
extern void init_zpcstats();
@@ -1439,11 +1433,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
#ifdef NMV_STATS
init_nmvstats();
#endif
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_STATS
- init_nzcstats();
-#endif
-#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
init_zpcstats();
@@ -1654,13 +1643,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->common.error.setjmp = 0;
vp9_zero(cpi->y_uv_mode_count)
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_zero(cm->fc.nzc_counts_4x4);
- vp9_zero(cm->fc.nzc_counts_8x8);
- vp9_zero(cm->fc.nzc_counts_16x16);
- vp9_zero(cm->fc.nzc_counts_32x32);
- vp9_zero(cm->fc.nzc_pcat_counts);
-#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zero(cm->fc.zpc_counts_4x4);
vp9_zero(cm->fc.zpc_counts_8x8);
@@ -1694,12 +1676,6 @@ void vp9_remove_compressor(VP9_PTR *ptr) {
if (cpi->pass != 1)
print_nmvstats();
#endif
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_STATS
- if (cpi->pass != 1)
- print_nzcstats();
-#endif
-#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
if (cpi->pass != 1)
@@ -3324,9 +3300,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_NONZEROCOUNT
- vp9_adapt_nzc_probs(&cpi->common);
-#endif
#if CONFIG_CODE_ZEROGROUP
vp9_adapt_zpc_probs(&cpi->common);
#endif
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index a6cfe9367..e6a2a3183 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -114,18 +114,6 @@ typedef struct {
int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_prob nzc_probs_4x4
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES];
- vp9_prob nzc_probs_8x8
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES];
- vp9_prob nzc_probs_16x16
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES];
- vp9_prob nzc_probs_32x32
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES];
- vp9_prob nzc_pcat_probs[MAX_NZC_CONTEXTS]
- [NZC_TOKENS_EXTRA][NZC_BITS_EXTRA];
-#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zpc_probs zpc_probs_4x4;
vp9_zpc_probs zpc_probs_8x8;
@@ -493,25 +481,6 @@ typedef struct VP9_COMP {
vp9_coeff_probs frame_coef_probs_32x32[BLOCK_TYPES];
vp9_coeff_stats frame_branch_ct_32x32[BLOCK_TYPES];
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_prob frame_nzc_probs_4x4
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES];
- unsigned int frame_nzc_branch_ct_4x4
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES][2];
- vp9_prob frame_nzc_probs_8x8
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES];
- unsigned int frame_nzc_branch_ct_8x8
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES][2];
- vp9_prob frame_nzc_probs_16x16
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES];
- unsigned int frame_nzc_branch_ct_16x16
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES][2];
- vp9_prob frame_nzc_probs_32x32
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES];
- unsigned int frame_nzc_branch_ct_32x32
- [MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES][2];
-#endif
-
int gfu_boost;
int last_boost;
int kf_boost;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 80d984965..18f0f4fa0 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -45,9 +45,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
const int *pt_scan;
-#if CONFIG_CODE_NONZEROCOUNT
- int nzc = 0;
-#endif
switch (tx_type) {
case ADST_DCT:
@@ -87,9 +84,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
if (y) {
eob = i; // last nonzero coeffs
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
}
}
@@ -97,9 +91,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
}
xd->plane[0].eobs[b_idx] = eob + 1;
-#if CONFIG_CODE_NONZEROCOUNT
- xd->nzcs[b_idx] = nzc;
-#endif
}
void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
@@ -123,9 +114,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
-#if CONFIG_CODE_NONZEROCOUNT
- int nzc = 0;
-#endif
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
@@ -157,9 +145,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
if (y) {
eob = i; // last nonzero coeffs
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
}
}
@@ -167,9 +152,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
}
xd->plane[pb_idx.plane].eobs[pb_idx.block] = eob + 1;
-#if CONFIG_CODE_NONZEROCOUNT
- xd->nzcs[b_idx] = nzc;
-#endif
}
void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
@@ -216,9 +198,6 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
-#if CONFIG_CODE_NONZEROCOUNT
- int nzc = 0;
-#endif
eob = -1;
@@ -242,9 +221,6 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
if (y) {
eob = 0; // last nonzero coeffs
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
zero_run = 0;
}
}
@@ -271,22 +247,13 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
if (y) {
eob = i; // last nonzero coeffs
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
zero_run = 0;
}
}
}
xd->plane[pb_idx.plane].eobs[pb_idx.block] = eob + 1;
-#if CONFIG_CODE_NONZEROCOUNT
- xd->nzcs[b_idx] = nzc;
-#endif
} else {
xd->plane[pb_idx.plane].eobs[pb_idx.block] = 0;
-#if CONFIG_CODE_NONZEROCOUNT
- xd->nzcs[b_idx] = 0;
-#endif
}
}
@@ -297,18 +264,12 @@ static void quantize(int16_t *zbin_boost_orig_ptr,
int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr,
int16_t *dequant_ptr, int zbin_oq_value,
uint16_t *eob_ptr,
-#if CONFIG_CODE_NONZEROCOUNT
- uint16_t *nzc_ptr,
-#endif
const int *scan, int mul) {
int i, rc, eob;
int zbin;
int x, y, z, sz;
int zero_run = 0;
int16_t *zbin_boost_ptr = zbin_boost_orig_ptr;
-#if CONFIG_CODE_NONZEROCOUNT
- int nzc = 0;
-#endif
vpx_memset(qcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
vpx_memset(dqcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
@@ -337,18 +298,12 @@ static void quantize(int16_t *zbin_boost_orig_ptr,
if (y) {
eob = i; // last nonzero coeffs
zero_run = 0;
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
}
}
}
}
*eob_ptr = eob + 1;
-#if CONFIG_CODE_NONZEROCOUNT
- *nzc_ptr = nzc;
-#endif
}
void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
@@ -384,9 +339,6 @@ void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
d->dequant,
b->zbin_extra,
&xd->plane[pb_idx.plane].eobs[pb_idx.block],
-#if CONFIG_CODE_NONZEROCOUNT
- &xd->nzcs[b_idx],
-#endif
pt_scan, 1);
}
@@ -410,9 +362,6 @@ void vp9_regular_quantize_b_32x32(MACROBLOCK *mb, int b_idx, int y_blocks) {
d->dequant,
b->zbin_extra,
&xd->plane[pb_idx.plane].eobs[pb_idx.block],
-#if CONFIG_CODE_NONZEROCOUNT
- &xd->nzcs[b_idx],
-#endif
vp9_default_zig_zag1d_32x32, 2);
}
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 30889d3e8..7a419fb61 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -172,13 +172,6 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
#if CONFIG_COMP_INTERINTRA_PRED
cc->interintra_prob = cm->fc.interintra_prob;
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_copy(cc->nzc_probs_4x4, cm->fc.nzc_probs_4x4);
- vp9_copy(cc->nzc_probs_8x8, cm->fc.nzc_probs_8x8);
- vp9_copy(cc->nzc_probs_16x16, cm->fc.nzc_probs_16x16);
- vp9_copy(cc->nzc_probs_32x32, cm->fc.nzc_probs_32x32);
- vp9_copy(cc->nzc_pcat_probs, cm->fc.nzc_pcat_probs);
-#endif
#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);
@@ -241,13 +234,6 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
#if CONFIG_COMP_INTERINTRA_PRED
cm->fc.interintra_prob = cc->interintra_prob;
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_copy(cm->fc.nzc_probs_4x4, cc->nzc_probs_4x4);
- vp9_copy(cm->fc.nzc_probs_8x8, cc->nzc_probs_8x8);
- vp9_copy(cm->fc.nzc_probs_16x16, cc->nzc_probs_16x16);
- vp9_copy(cm->fc.nzc_probs_32x32, cc->nzc_probs_32x32);
- vp9_copy(cm->fc.nzc_pcat_probs, cc->nzc_pcat_probs);
-#endif
#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);
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index c3cf31818..7a725b009 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -162,60 +162,6 @@ static void fill_token_costs(vp9_coeff_count *c,
}
}
-#if CONFIG_CODE_NONZEROCOUNT
-static void fill_nzc_costs(VP9_COMP *cpi, TX_SIZE tx_size) {
- int nzc_context, r, b, nzc, values;
- int cost[16];
- values = (16 << (2 * tx_size)) + 1;
-
- for (nzc_context = 0; nzc_context < MAX_NZC_CONTEXTS; ++nzc_context) {
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- unsigned int *nzc_costs;
- if (tx_size == TX_4X4) {
- vp9_cost_tokens(cost,
- cpi->common.fc.nzc_probs_4x4[nzc_context][r][b],
- vp9_nzc4x4_tree);
- nzc_costs = cpi->mb.nzc_costs_4x4[nzc_context][r][b];
- } else if (tx_size == TX_8X8) {
- vp9_cost_tokens(cost,
- cpi->common.fc.nzc_probs_8x8[nzc_context][r][b],
- vp9_nzc8x8_tree);
- nzc_costs = cpi->mb.nzc_costs_8x8[nzc_context][r][b];
- } else if (tx_size == TX_16X16) {
- vp9_cost_tokens(cost,
- cpi->common.fc.nzc_probs_16x16[nzc_context][r][b],
- vp9_nzc16x16_tree);
- nzc_costs = cpi->mb.nzc_costs_16x16[nzc_context][r][b];
- } else {
- vp9_cost_tokens(cost,
- cpi->common.fc.nzc_probs_32x32[nzc_context][r][b],
- vp9_nzc32x32_tree);
- nzc_costs = cpi->mb.nzc_costs_32x32[nzc_context][r][b];
- }
-
- for (nzc = 0; nzc < values; ++nzc) {
- int e, c, totalcost = 0;
- c = codenzc(nzc);
- totalcost = cost[c];
- if ((e = vp9_extranzcbits[c])) {
- int x = nzc - vp9_basenzcvalue[c];
- while (e--) {
- totalcost += vp9_cost_bit(
- cpi->common.fc.nzc_pcat_probs[nzc_context]
- [c - NZC_TOKENS_NOEXTRA][e],
- ((x >> e) & 1));
- }
- }
- nzc_costs[nzc] = totalcost;
- }
- }
- }
- }
-}
-#endif
-
-
static int rd_iifactor[32] = { 4, 4, 3, 2, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -313,12 +259,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
cpi->common.fc.coef_probs_16x16, TX_16X16);
fill_token_costs(cpi->mb.token_costs[TX_32X32],
cpi->common.fc.coef_probs_32x32, TX_32X32);
-#if CONFIG_CODE_NONZEROCOUNT
- fill_nzc_costs(cpi, TX_4X4);
- fill_nzc_costs(cpi, TX_8X8);
- fill_nzc_costs(cpi, TX_16X16);
- fill_nzc_costs(cpi, TX_32X32);
-#endif
for (i = 0; i < 2; i++)
vp9_cost_tokens(cpi->mb.partition_cost[i],
@@ -376,11 +316,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
sizeof(ENTROPY_CONTEXT_PLANES)/sizeof(ENTROPY_CONTEXT);
TX_TYPE tx_type = DCT_DCT;
-#if CONFIG_CODE_NONZEROCOUNT
- const int nzc_used = get_nzc_used(tx_size);
- int nzc_context = vp9_get_nzc_context(cm, xd, ib);
- unsigned int *nzc_cost;
-#endif
#if CONFIG_CODE_ZEROGROUP
int last_nz_pos[3] = {-1, -1, -1}; // Encoder only
int is_eoo_list[3] = {0, 0, 0};
@@ -415,9 +350,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
get_tx_type_4x4(xd, ib) : DCT_DCT;
a_ec = *a;
l_ec = *l;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_4x4[nzc_context][ref][type];
-#endif
coef_probs = cm->fc.coef_probs_4x4;
seg_eob = 16;
if (tx_type == ADST_DCT) {
@@ -447,9 +379,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
} else {
scan = vp9_default_zig_zag1d_8x8;
}
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_8x8[nzc_context][ref][type];
-#endif
coef_probs = cm->fc.coef_probs_8x8;
seg_eob = 64;
#if CONFIG_CODE_ZEROGROUP
@@ -470,9 +399,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
} else {
scan = vp9_default_zig_zag1d_16x16;
}
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_16x16[nzc_context][ref][type];
-#endif
coef_probs = cm->fc.coef_probs_16x16;
seg_eob = 256;
if (type == PLANE_TYPE_UV) {
@@ -489,9 +415,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
-#if CONFIG_CODE_NONZEROCOUNT
- nzc_cost = mb->nzc_costs_32x32[nzc_context][ref][type];
-#endif
coef_probs = cm->fc.coef_probs_32x32;
seg_eob = 1024;
if (type == PLANE_TYPE_UV) {
@@ -524,11 +447,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
nb = vp9_get_coef_neighbors_handle(scan, &pad);
default_eob = seg_eob;
-#if CONFIG_CODE_NONZEROCOUNT
- if (!nzc_used)
-#endif
- if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
- seg_eob = 0;
+ if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
+ seg_eob = 0;
/* sanity check to ensure that we do not have spurious non-zero q values */
if (eob < seg_eob)
@@ -545,16 +465,10 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
#endif
{
-#if CONFIG_CODE_NONZEROCOUNT
- int nzc = 0;
-#endif
for (c = 0; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].token;
int band = get_coef_band(scan, tx_size, c);
-#if CONFIG_CODE_NONZEROCOUNT
- nzc += (v != 0);
-#endif
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
#if CONFIG_CODE_ZEROGROUP
@@ -569,11 +483,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#else
cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v];
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- if (!nzc_used)
-#endif
- if (!c || token_cache[scan[c - 1]])
- cost += vp9_cost_bit(coef_probs[type][ref][band][pt][0], 1);
+ 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) {
@@ -632,22 +543,17 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
is_last_zero[o] = (t == ZERO_TOKEN);
#endif
}
-#if CONFIG_CODE_NONZEROCOUNT
- if (nzc_used)
- cost += nzc_cost[nzc];
- else
-#endif
- if (c < seg_eob) {
- if (c)
- pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
- cost += mb->token_costs[tx_size][type][ref]
- [get_coef_band(scan, tx_size, c)]
- [pt][DCT_EOB_TOKEN];
- }
+ if (c < seg_eob) {
+ if (c)
+ pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+ cost += mb->token_costs[tx_size][type][ref]
+ [get_coef_band(scan, tx_size, c)]
+ [pt][DCT_EOB_TOKEN];
+ }
}
- // is eob first coefficient;
- pt = (c > 0);
+ // is eob first coefficient;
+ pt = (c > 0);
*a = *l = pt;
if (tx_size >= TX_8X8) {
a[1] = l[1] = pt;
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index dd9efe6db..f6a720651 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -36,21 +36,6 @@ extern vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES];
extern vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES];
#endif /* ENTROPY_STATS */
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_STATS
-unsigned int nzc_counts_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC4X4_TOKENS];
-unsigned int nzc_counts_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC8X8_TOKENS];
-unsigned int nzc_counts_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC16X16_TOKENS];
-unsigned int nzc_counts_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
- [NZC32X32_TOKENS];
-unsigned int nzc_pcat_counts[MAX_NZC_CONTEXTS][NZC_TOKENS_EXTRA]
- [NZC_BITS_EXTRA][2];
-#endif
-#endif
-
static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2];
const TOKENVALUE *vp9_dct_value_tokens_ptr;
static int dct_value_cost[DCT_MAX_VALUE * 2];
@@ -147,12 +132,6 @@ static void tokenize_b(VP9_COMP *cpi,
vp9_zpc_count *zpc_count;
uint8_t token_cache_full[1024];
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- const int nzc_used = get_nzc_used(tx_size);
- int zerosleft = 0, nzc = 0;
- if (eob == 0)
- assert(xd->nzcs[ib] == 0);
-#endif
#if CONFIG_CODE_ZEROGROUP
vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache));
#endif
@@ -343,10 +322,6 @@ static void tokenize_b(VP9_COMP *cpi,
rc = scan[c];
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
-#if CONFIG_CODE_NONZEROCOUNT
- if (nzc_used)
- zerosleft = seg_eob - xd->nzcs[ib] - c + nzc;
-#endif
if (c < eob) {
v = qcoeff_ptr[rc];
assert(-DCT_MAX_VALUE <= v && v < DCT_MAX_VALUE);
@@ -354,22 +329,11 @@ static void tokenize_b(VP9_COMP *cpi,
t->extra = vp9_dct_value_tokens_ptr[v].extra;
token = vp9_dct_value_tokens_ptr[v].token;
} else {
-#if CONFIG_CODE_NONZEROCOUNT
- if (nzc_used)
- break;
- else
-#endif
- token = DCT_EOB_TOKEN;
+ token = DCT_EOB_TOKEN;
}
t->token = token;
t->context_tree = coef_probs[type][ref][band][pt];
-#if CONFIG_CODE_NONZEROCOUNT
- // Skip zero node if there are no zeros left
- if (nzc_used)
- t->skip_eob_node = 1 + (zerosleft == 0);
- else
-#endif
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
@@ -391,9 +355,6 @@ static void tokenize_b(VP9_COMP *cpi,
if (!t->skip_eob_node)
++cpi->common.fc.eob_branch_counts[tx_size][type][ref][band][pt];
}
-#if CONFIG_CODE_NONZEROCOUNT
- nzc += (v != 0);
-#endif
token_cache[scan[c]] = token;
#if CONFIG_CODE_ZEROGROUP
if (token == ZERO_TOKEN && !t->skip_coef_val) {
@@ -464,10 +425,7 @@ static void tokenize_b(VP9_COMP *cpi,
is_last_zero[o] = (token == ZERO_TOKEN);
#endif
++t;
-} while (c < eob && ++c < seg_eob);
-#if CONFIG_CODE_NONZEROCOUNT
-assert(nzc == xd->nzcs[ib]);
-#endif
+ } while (c < eob && ++c < seg_eob);
*tp = t;
a_ec = l_ec = (c > 0); /* 0 <-> all coeff data is zero */
@@ -860,9 +818,6 @@ static void stuff_b(VP9_COMP *cpi,
TOKENEXTRA *t = *tp;
const int ref = mbmi->ref_frame != INTRA_FRAME;
ENTROPY_CONTEXT *a, *l, *a1, *l1, *a2, *l2, *a3, *l3, a_ec, l_ec;
-#if CONFIG_CODE_NONZEROCOUNT
- const int nzc_used = get_nzc_used(tx_size);
-#endif
if (sb_type == BLOCK_SIZE_SB64X64) {
a = (ENTROPY_CONTEXT *)xd->above_context +
@@ -928,26 +883,20 @@ static void stuff_b(VP9_COMP *cpi,
break;
}
-#if CONFIG_CODE_NONZEROCOUNT
- if (!nzc_used) {
-#endif
- pt = combine_entropy_contexts(a_ec, l_ec);
- band = 0;
- t->token = DCT_EOB_TOKEN;
- t->context_tree = probs[type][ref][band][pt];
- t->skip_eob_node = 0;
+ pt = combine_entropy_contexts(a_ec, l_ec);
+ band = 0;
+ t->token = DCT_EOB_TOKEN;
+ t->context_tree = probs[type][ref][band][pt];
+ t->skip_eob_node = 0;
#if CONFIG_CODE_ZEROGROUP
- t->skip_coef_val = 0;
+ t->skip_coef_val = 0;
#endif
- ++t;
- *tp = t;
- if (!dry_run) {
- ++counts[type][ref][band][pt][DCT_EOB_TOKEN];
- }
-#if CONFIG_CODE_NONZEROCOUNT
+ ++t;
+ *tp = t;
+ if (!dry_run) {
+ ++counts[type][ref][band][pt][DCT_EOB_TOKEN];
}
-#endif
- *a = *l = 0;
+ *a = *l = 0;
if (tx_size == TX_8X8) {
a[1] = 0;
l[1] = 0;