summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encodemb.c
diff options
context:
space:
mode:
authorDeb Mukherjee <debargha@google.com>2013-05-08 10:04:14 -0700
committerDeb Mukherjee <debargha@google.com>2013-05-29 16:25:52 -0700
commitb8b3f1a46d756bef73cb4f3cd6990a01cbacaa25 (patch)
tree88d9302e6878b729b91b761e8fb9adf363577830 /vp9/encoder/vp9_encodemb.c
parent38cb616fbfcc3b372bb14325c897af852b02a4c7 (diff)
downloadlibvpx-b8b3f1a46d756bef73cb4f3cd6990a01cbacaa25.tar
libvpx-b8b3f1a46d756bef73cb4f3cd6990a01cbacaa25.tar.gz
libvpx-b8b3f1a46d756bef73cb4f3cd6990a01cbacaa25.tar.bz2
libvpx-b8b3f1a46d756bef73cb4f3cd6990a01cbacaa25.zip
Balancing coef-tree to reduce bool decodes
This patch changes the coefficient tree to move the EOB to below the ZERO node in order to save number of bool decodes. The advantages of moving EOB one step down as opposed to two steps down in the other parallel patch are: 1. The coef modeling based on the One-node becomes independent of the tree structure above it, and 2. Fewer conext/counter increases are needed. The drawback is that the potential savings in bool decodes will be less, but assuming that 0s are much more predominant than 1's the potential savings is still likely to be substantial. Results on derf300: -0.237% Change-Id: Ie784be13dc98291306b338e8228703a4c2ea2242
Diffstat (limited to 'vp9/encoder/vp9_encodemb.c')
-rw-r--r--vp9/encoder/vp9_encodemb.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 755ff21bf..98ea98031 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -215,10 +215,21 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
band = get_coef_band(band_translate, i + 1);
pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache,
pad, default_eob);
+#if CONFIG_BALANCED_COEFTREE
rate0 +=
- mb->token_costs[tx_size][type][ref][band][pt][tokens[next][0].token];
+ mb->token_costs_noskip[tx_size][type][ref][band][pt]
+ [tokens[next][0].token];
rate1 +=
- mb->token_costs[tx_size][type][ref][band][pt][tokens[next][1].token];
+ mb->token_costs_noskip[tx_size][type][ref][band][pt]
+ [tokens[next][1].token];
+#else
+ rate0 +=
+ mb->token_costs[tx_size][type][ref][band][pt]
+ [tokens[next][0].token];
+ rate1 +=
+ mb->token_costs[tx_size][type][ref][band][pt]
+ [tokens[next][1].token];
+#endif
}
UPDATE_RD_COST();
/* And pick the best. */
@@ -266,14 +277,32 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
if (t0 != DCT_EOB_TOKEN) {
pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache,
pad, default_eob);
+#if CONFIG_BALANCED_COEFTREE
+ if (!x)
+ rate0 += mb->token_costs[tx_size][type][ref][band][pt][
+ tokens[next][0].token];
+ else
+ rate0 += mb->token_costs_noskip[tx_size][type][ref][band][pt][
+ tokens[next][0].token];
+#else
rate0 += mb->token_costs[tx_size][type][ref][band][pt][
tokens[next][0].token];
+#endif
}
if (t1 != DCT_EOB_TOKEN) {
pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache,
pad, default_eob);
+#if CONFIG_BALANCED_COEFTREE
+ if (!x)
+ rate1 += mb->token_costs[tx_size][type][ref][band][pt][
+ tokens[next][1].token];
+ else
+ rate1 += mb->token_costs_noskip[tx_size][type][ref][band][pt][
+ tokens[next][1].token];
+#else
rate1 += mb->token_costs[tx_size][type][ref][band][pt][
tokens[next][1].token];
+#endif
}
}
@@ -326,8 +355,13 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
error1 = tokens[next][1].error;
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
+#if CONFIG_BALANCED_COEFTREE
+ rate0 += mb->token_costs_noskip[tx_size][type][ref][band][pt][t0];
+ rate1 += mb->token_costs_noskip[tx_size][type][ref][band][pt][t1];
+#else
rate0 += mb->token_costs[tx_size][type][ref][band][pt][t0];
rate1 += mb->token_costs[tx_size][type][ref][band][pt][t1];
+#endif
UPDATE_RD_COST();
best = rd_cost1 < rd_cost0;
final_eob = i0 - 1;