ref: 2d4711c9ead0ae1e03cf8fb06a50eb614dac0e52
parent: 1e674fdb3338c137128eac6259bed85583b2925e
author: Colin Lee <[email protected]>
date: Tue Jun 16 05:51:38 EDT 2020
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.
--- a/src/refmvs.c
+++ b/src/refmvs.c
@@ -184,8 +184,11 @@
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,