diff options
author | James Zern <jzern@google.com> | 2016-09-29 19:11:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-09-29 19:11:35 +0000 |
commit | 691ef20272d398c5802b185859a797af3ce1e289 (patch) | |
tree | 999644627e5a980cd5588180e2c4d1380529ab5f | |
parent | e094e151de32659fae15b3567e5dead4a5ba310d (diff) | |
parent | 93c823e24b7b5b91de729217075c08e9082b80bd (diff) | |
download | libvpx-691ef20272d398c5802b185859a797af3ce1e289.tar libvpx-691ef20272d398c5802b185859a797af3ce1e289.tar.gz libvpx-691ef20272d398c5802b185859a797af3ce1e289.tar.bz2 libvpx-691ef20272d398c5802b185859a797af3ce1e289.zip |
Merge changes I11786887,Ia91823ad
* changes:
vpx_dsp/get_prob: relocate den == 0 test
vpx_dsp/get_prob: make clip_prob branchless
-rw-r--r-- | vpx_dsp/prob.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/vpx_dsp/prob.h b/vpx_dsp/prob.h index 3127a00bb..5656ddbab 100644 --- a/vpx_dsp/prob.h +++ b/vpx_dsp/prob.h @@ -11,6 +11,8 @@ #ifndef VPX_DSP_PROB_H_ #define VPX_DSP_PROB_H_ +#include <assert.h> + #include "./vpx_config.h" #include "./vpx_dsp_common.h" @@ -43,17 +45,20 @@ typedef int8_t vpx_tree_index; typedef const vpx_tree_index vpx_tree[]; -static INLINE vpx_prob clip_prob(int p) { - return (p > 255) ? 255 : (p < 1) ? 1 : p; -} - static INLINE vpx_prob get_prob(unsigned int num, unsigned int den) { - if (den == 0) return 128u; - return clip_prob((int)(((int64_t)num * 256 + (den >> 1)) / den)); + assert(den != 0); + { + const int p = (int)(((int64_t)num * 256 + (den >> 1)) / den); + // (p > 255) ? 255 : (p < 1) ? 1 : p; + const int clipped_prob = p | ((255 - p) >> 23) | (p == 0); + return (vpx_prob)clipped_prob; + } } static INLINE vpx_prob get_binary_prob(unsigned int n0, unsigned int n1) { - return get_prob(n0, n0 + n1); + const unsigned int den = n0 + n1; + if (den == 0) return 128u; + return get_prob(n0, den); } /* This function assumes prob1 and prob2 are already within [1,255] range. */ |