summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaowu Xu <yaowu@google.com>2013-10-10 11:00:57 -0700
committerYaowu Xu <yaowu@google.com>2013-10-10 11:01:50 -0700
commitb47cef056e51751d5d7b1cb50f91a71110294a9c (patch)
tree900fa90132542dc3c9f52cc5a75087b7f6ed4401
parent850a919640030a7a9813163491cf7c5bde77ce65 (diff)
downloadlibvpx-b47cef056e51751d5d7b1cb50f91a71110294a9c.tar
libvpx-b47cef056e51751d5d7b1cb50f91a71110294a9c.tar.gz
libvpx-b47cef056e51751d5d7b1cb50f91a71110294a9c.tar.bz2
libvpx-b47cef056e51751d5d7b1cb50f91a71110294a9c.zip
change to avoid out-of-range computation
Change-Id: Id5e31833a0ef40de9f64c2f5674af7083233bf14
-rw-r--r--vp9/encoder/vp9_rdopt.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 761c5d65e..e2d24a2de 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -3642,10 +3642,17 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
// values, which actually are bigger than this_rd itself. This can
// cause negative best_filter_rd[] values, which is obviously silly.
// Therefore, if filter_cache < ref, we do an adjusted calculation.
- if (cpi->rd_filter_cache[i] >= ref)
+ if (cpi->rd_filter_cache[i] >= ref) {
adj_rd = this_rd + cpi->rd_filter_cache[i] - ref;
- else // FIXME(rbultje) do this for comppred also
- adj_rd = this_rd - (ref - cpi->rd_filter_cache[i]) * this_rd / ref;
+ } else {
+ // FIXME(rbultje) do this for comppsred also
+ //
+ // To prevent out-of-range computation in
+ // adj_rd = cpi->rd_filter_cache[i] * this_rd / ref
+ // cpi->rd_filter_cache[i] / ref is converted to a 256 based ratio.
+ int tmp = cpi->rd_filter_cache[i] * 256 / ref;
+ adj_rd = (this_rd * tmp) >> 8;
+ }
best_filter_rd[i] = MIN(best_filter_rd[i], adj_rd);
}
}