From b8b3f1a46d756bef73cb4f3cd6990a01cbacaa25 Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Wed, 8 May 2013 10:04:14 -0700 Subject: 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 --- vp9/encoder/vp9_encodemb.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'vp9/encoder/vp9_encodemb.c') 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; -- cgit v1.2.3