Commit 0b9b3d86 authored by Geza Lore's avatar Geza Lore

Add a few branch hints to vp10_optimize_b.

vp10_optimize_b now takes between 40% to 60% of the TOTAL runtime
of the encoder, depending on bit-rate. It also contains 2/3 to 3/4
of the mispredicted branch instructions in the whole program.

Adding a few branch hints makes vp10_optimize_b around 2-5% faster
(dependig on bit-rate) when compiled with gcc/clang.

Change-Id: I1572733e18b4166bc10591b958c5018a9561fa2b
parent 7c393d09
......@@ -160,7 +160,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
next_shortcut = shortcut;
/* Only add a trellis state for non-zero coefficients. */
if (x) {
if (UNLIKELY(x)) {
error0 = tokens[next][0].error;
error1 = tokens[next][1].error;
/* Evaluate the first possibility for this state. */
......@@ -204,7 +204,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
rate1 = tokens[next][1].rate;
// The threshold of 3 is empirically obtained.
if (abs(x) > 3) {
if (UNLIKELY(abs(x) > 3)) {
shortcut = 0;
} else {
#if CONFIG_NEW_QUANT
......@@ -233,7 +233,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
best_index[i][1] = best_index[i][0];
next = i;
if (!(--band_left)) {
if (UNLIKELY(!(--band_left))) {
--band_counts;
band_left = *band_counts;
--token_costs;
......@@ -255,7 +255,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
}
if (next_shortcut) {
if (next < default_eob) {
if (LIKELY(next < default_eob)) {
if (t0 != EOB_TOKEN) {
token_cache[rc] = vp10_pt_energy_class[t0];
pt = get_coef_context(nb, token_cache, i + 1);
......@@ -350,7 +350,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
/* Don't update next, because we didn't add a new node. */
}
if (!(--band_left)) {
if (UNLIKELY(!(--band_left))) {
--band_counts;
band_left = *band_counts;
--token_costs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment