diff options
author | Colin Lee <colinlee10@gmail.com> | 2020-06-16 12:51:38 +0300 |
---|---|---|
committer | Colin Lee <colinlee10@gmail.com> | 2020-06-17 00:32:23 +0300 |
commit | 2d4711c9ead0ae1e03cf8fb06a50eb614dac0e52 (patch) | |
tree | c5b9b740bf5134eb1d01c3e678b5cd3dded333cd /src/refmvs.c | |
parent | 1e674fdb3338c137128eac6259bed85583b2925e (diff) |
Add clamping back to mv projection
Clamping in the motion vector projection calculation is required by spec.
In commit aca57bf3db00c29e90605656f1015561d1d67c2d
a rewrite of the function omitted the clamping. This commit readds the
clamping.
Diffstat (limited to 'src/refmvs.c')
-rw-r--r-- | src/refmvs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/refmvs.c b/src/refmvs.c index 2039bed..b554a3c 100644 --- a/src/refmvs.c +++ b/src/refmvs.c @@ -184,8 +184,11 @@ static inline union mv mv_projection(const union mv mv, const int num, const int assert(num > -32 && num < 32); const int dm = div_mult[den]; const int y = mv.y * num * dm, x = mv.x * num * dm; - return (union mv) { .y = (y + 8192 + (y >> 31)) >> 14, - .x = (x + 8192 + (x >> 31)) >> 14 }; + // Round and clip according to AV1 spec section 7.9.3 + return (union mv) { // 0x3fff == (1 << 14) - 1 + .y = iclip((y + 8192 + (y >> 31)) >> 14, -0x3fff, 0x3fff), + .x = iclip((x + 8192 + (x >> 31)) >> 14, -0x3fff, 0x3fff) + }; } static void add_temporal_candidate(const refmvs_frame *const rf, |