ref: 85786a8ddb9cccaeaa0ff586cfa3332f6c08c56c
parent: 188420f4fda3161bf69a5b571476a23bdb55b8ec
parent: dba1d1a63dd170fc7d5a2af27abaa95484c4c75f
author: Jingning Han <[email protected]>
date: Mon Jun 20 12:48:01 EDT 2016
Merge "Port optimize_b speed-up from vp10"
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -50,10 +50,6 @@
pd->dst.buf, pd->dst.stride);
}
-#define RDTRUNC(RM, DM, R, D) \
- (((1 << (VP9_PROB_COST_SHIFT - 1)) + (R) * (RM)) & \
- ((1 << VP9_PROB_COST_SHIFT) - 1))
-
// TODO(aconverse): Re-pack this structure.
typedef struct vp9_token_state {
int rate;
@@ -69,10 +65,6 @@
{\
rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);\
rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);\
- if (rd_cost0 == rd_cost1) {\
- rd_cost0 = RDTRUNC(rdmult, rddiv, rate0, error0);\
- rd_cost1 = RDTRUNC(rdmult, rddiv, rate1, error1);\
- }\
}
// This function is a place holder for now but may ultimately need
@@ -103,7 +95,7 @@
const int eob = p->eobs[block];
const PLANE_TYPE type = get_plane_type(plane);
const int default_eob = 16 << (tx_size << 1);
- const int mul = 1 + (tx_size == TX_32X32);
+ int shift = (tx_size == TX_32X32);
const int16_t *dequant_ptr = pd->dequant;
const uint8_t *const band_translate = get_band_translate(tx_size);
const scan_order *const so = get_scan(xd, tx_size, type, block);
@@ -166,7 +158,7 @@
/* And pick the best. */
best = rd_cost1 < rd_cost0;
base_bits = vp9_get_cost(t0, e0, cat6_high_cost);
- dx = mul * (dqcoeff[rc] - coeff[rc]);
+ dx = (dqcoeff[rc] - coeff[rc]) * (1 << shift);
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
dx >>= xd->bd - 8;
@@ -184,8 +176,8 @@
rate0 = tokens[next][0].rate;
rate1 = tokens[next][1].rate;
- if ((abs(x) * dequant_ptr[rc != 0] > abs(coeff[rc]) * mul) &&
- (abs(x) * dequant_ptr[rc != 0] < abs(coeff[rc]) * mul +
+ if ((abs(x) * dequant_ptr[rc != 0] > (abs(coeff[rc]) << shift)) &&
+ (abs(x) * dequant_ptr[rc != 0] < (abs(coeff[rc]) << shift) +
dequant_ptr[rc != 0]))
shortcut = 1;
else
@@ -194,6 +186,11 @@
if (shortcut) {
sz = -(x < 0);
x -= 2 * sz + 1;
+ } else {
+ tokens[i][1] = tokens[i][0];
+ best_index[i][1] = best_index[i][0];
+ next = i;
+ continue;
}
/* Consider both possible successor states. */
@@ -293,7 +290,9 @@
}
qcoeff[rc] = x;
- dqcoeff[rc] = (x * dequant_ptr[rc != 0]) / mul;
+ dqcoeff[rc] = abs(x * dequant_ptr[rc != 0]) >> shift;
+ if (x < 0)
+ dqcoeff[rc] = -dqcoeff[rc];
next = tokens[i][best].next;
best = best_index[i][best];