summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@google.com>2013-02-06 17:16:36 -0800
committerRonald S. Bultje <rbultje@google.com>2013-02-08 16:32:24 -0800
commit639b863d2276d8100a5e585fa5ab9bf2d3983946 (patch)
tree1fc9f23cf7914295a5646cb37116d542c54d7431 /vp9/encoder
parent6dfc95fe63a52945350a7c8a234e87a4a55645db (diff)
downloadlibvpx-639b863d2276d8100a5e585fa5ab9bf2d3983946.tar
libvpx-639b863d2276d8100a5e585fa5ab9bf2d3983946.tar.gz
libvpx-639b863d2276d8100a5e585fa5ab9bf2d3983946.tar.bz2
libvpx-639b863d2276d8100a5e585fa5ab9bf2d3983946.zip
Make cost_coeffs() more efficient.
Cache the constant offset in one variable to prevent re-loading that in each loop iteration, and mark the function as inline so we can use the fact that the transform size is always known in the caller. Almost 1% faster encoding overall. Change-Id: Id78325a60b025057d8f4ecd9003a74086ccbf85a
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_rdopt.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 370374164..e45e8d692 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -424,11 +424,11 @@ int vp9_uvsse(MACROBLOCK *x) {
#else
#define PT pt
#endif
-static int cost_coeffs(MACROBLOCK *mb,
- BLOCKD *b, PLANE_TYPE type,
- ENTROPY_CONTEXT *a,
- ENTROPY_CONTEXT *l,
- TX_SIZE tx_size) {
+static INLINE int cost_coeffs(MACROBLOCK *mb,
+ BLOCKD *b, PLANE_TYPE type,
+ ENTROPY_CONTEXT *a,
+ ENTROPY_CONTEXT *l,
+ TX_SIZE tx_size) {
int pt;
const int eob = b->eob;
MACROBLOCKD *xd = &mb->e_mbd;
@@ -440,6 +440,9 @@ static int cost_coeffs(MACROBLOCK *mb,
int16_t *qcoeff_ptr = b->qcoeff;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type(xd, b) : DCT_DCT;
+ unsigned int (*token_costs)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] =
+ (tx_type == DCT_DCT) ? mb->token_costs[tx_size][type] :
+ mb->hybrid_token_costs[tx_size][type];
#if CONFIG_NEWCOEFCONTEXT
const int *neighbors;
int pn;
@@ -504,7 +507,7 @@ static int cost_coeffs(MACROBLOCK *mb,
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].Token;
- cost += mb->hybrid_token_costs[tx_size][type][band[c]][PT][t];
+ cost += token_costs[band[c]][PT][t];
cost += vp9_dct_value_cost_ptr[v];
pt = vp9_prev_token_class[t];
#if CONFIG_NEWCOEFCONTEXT
@@ -522,7 +525,7 @@ static int cost_coeffs(MACROBLOCK *mb,
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs[tx_size][type][band[c]][pt][t];
+ cost += token_costs[band[c]][pt][t];
cost += vp9_dct_value_cost_ptr[v];
pt = vp9_prev_token_class[t];
#if CONFIG_NEWCOEFCONTEXT