]> granicus.if.org Git - libvpx/commitdiff
vpx_dsp/get_prob: relocate den == 0 test m54-2840
authorJames Zern <jzern@google.com>
Thu, 29 Sep 2016 00:39:05 +0000 (17:39 -0700)
committerJames Zern <jzern@google.com>
Tue, 4 Oct 2016 22:18:58 +0000 (15:18 -0700)
to get_binary_prob(). the only other caller mode_mv_merge_probs() does
its own test on 0.

BUG=chromium:639712

Change-Id: I1178688706baeca2883f7aadbc254abb219a44ce
(cherry picked from commit 93c823e24b7b5b91de729217075c08e9082b80bd)

vpx_dsp/prob.h

index 4402cd30a5e932ab9b77fdb0f67e78d835446f8e..5656ddbab4dc82c02eeb26e8a1494c6b3419f978 100644 (file)
@@ -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"
 
@@ -44,7 +46,7 @@ typedef int8_t vpx_tree_index;
 typedef const vpx_tree_index vpx_tree[];
 
 static INLINE vpx_prob get_prob(unsigned int num, unsigned int den) {
-  if (den == 0) return 128u;
+  assert(den != 0);
   {
     const int p = (int)(((int64_t)num * 256 + (den >> 1)) / den);
     // (p > 255) ? 255 : (p < 1) ? 1 : p;
@@ -54,7 +56,9 @@ static INLINE vpx_prob get_prob(unsigned int num, unsigned int den) {
 }
 
 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. */