diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-04-10 01:10:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-10 01:10:32 +0000 |
commit | ca3e25812bb2faadd5b1feb1d6f4b16b4e0ce87b (patch) | |
tree | fe99aa97cf716403c59a8b5cf5773c48894c6d8f | |
parent | ec8b6875d57d31a92be5d0e1fac0aef2276724c9 (diff) | |
parent | 073990fb32f39c64e4ba9cbd5fb11bfc0c1f0aad (diff) | |
download | libvpx-ca3e25812bb2faadd5b1feb1d6f4b16b4e0ce87b.tar.gz |
Merge "DO NOT MERGE | libvpx: cherry pick fix to OOB of mv_cost index." into oc-mr1-dev
-rw-r--r-- | libvpx/vp8/encoder/mcomp.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libvpx/vp8/encoder/mcomp.c b/libvpx/vp8/encoder/mcomp.c index 970120f3b..b4a49a3b1 100644 --- a/libvpx/vp8/encoder/mcomp.c +++ b/libvpx/vp8/encoder/mcomp.c @@ -34,19 +34,22 @@ int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight) { * NEAREST for subsequent blocks. The "Weight" parameter allows, to a * limited extent, for some account to be taken of these factors. */ - return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] + - mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) * - Weight) >> - 7; + const int mv_idx_row = + clamp((mv->as_mv.row - ref->as_mv.row) >> 1, 0, MVvals); + const int mv_idx_col = + clamp((mv->as_mv.col - ref->as_mv.col) >> 1, 0, MVvals); + return ((mvcost[0][mv_idx_row] + mvcost[1][mv_idx_col]) * Weight) >> 7; } static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit) { /* Ignore mv costing if mvcost is NULL */ if (mvcost) { - return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] + - mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) * - error_per_bit + + const int mv_idx_row = + clamp((mv->as_mv.row - ref->as_mv.row) >> 1, 0, MVvals); + const int mv_idx_col = + clamp((mv->as_mv.col - ref->as_mv.col) >> 1, 0, MVvals); + return ((mvcost[0][mv_idx_row] + mvcost[1][mv_idx_col]) * error_per_bit + 128) >> 8; } |