shithub: libvpx

Download patch

ref: 8e5fa0aa0507b79f2f33b5b89d403999832f9b24
parent: a95758c881c4049a8a624975e9212b803afcc749
parent: 4e7cd38f9e13225f8a0c53cbf004169592d1efc9
author: Jim Bankoski <[email protected]>
date: Thu Aug 7 02:24:17 EDT 2014

Merge "vp9_rd.c: cleanup ugly expression"

--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -220,8 +220,6 @@
   }
 }
 
-static const int MAX_XSQ_Q10 = 245727;
-
 static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) {
   // NOTE: The tables below must be of the same size.
 
@@ -311,10 +309,10 @@
     *dist = 0;
   } else {
     int d_q10, r_q10;
+    static const uint32_t MAX_XSQ_Q10 = 245727;
     const uint64_t xsq_q10_64 =
         ((((uint64_t)qstep * qstep * n) << 10) + (var >> 1)) / var;
-    const int xsq_q10 = xsq_q10_64 > (uint64_t)MAX_XSQ_Q10 ?
-                        (int)MAX_XSQ_Q10 : (int)xsq_q10_64;
+    const int xsq_q10 = (int)MIN(xsq_q10_64, MAX_XSQ_Q10);
     model_rd_norm(xsq_q10, &r_q10, &d_q10);
     *rate = (n * r_q10 + 2) >> 2;
     *dist = (var * (int64_t)d_q10 + 512) >> 10;