ref: 05c6eca4db7f2abec32c9ce0fc325d9a0b933fb7
parent: 317a66693b690eadd886d55286a24f428d7c50e5
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Thu Jun 10 14:42:24 EDT 2010
Fix new MV clamping scheme for chroma MVs. The new scheme introduced in I68d35a2f did not clamp chroma MVs in the SPLITMV case, and clamped them incorrectly (to the luma plane bounds) in every other case. Because chroma MVs are computed from the luma MVs before clamping occurs, they could still point outside of the frame buffer and cause crashes. This clamping happens outside of the MV prediction loop, and so should not affect bitstream decoding.
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -149,7 +149,20 @@
mv->row = xd->mb_to_bottom_edge + (16 << 3);
}
+/* A version of the above function for chroma block MVs.*/
+static void clamp_uvmv_to_umv_border(MV *mv, const MACROBLOCKD *xd)
+{
+ if (2*mv->col < (xd->mb_to_left_edge - (19 << 3)))
+ mv->col = (xd->mb_to_left_edge - (16 << 3)) >> 1;
+ else if (2*mv->col > xd->mb_to_right_edge + (18 << 3))
+ mv->col = (xd->mb_to_right_edge + (16 << 3)) >> 1;
+ if (2*mv->row < (xd->mb_to_top_edge - (19 << 3)))
+ mv->row = (xd->mb_to_top_edge - (16 << 3)) >> 1;
+ else if (2*mv->row > xd->mb_to_bottom_edge + (18 << 3))
+ mv->row = (xd->mb_to_bottom_edge + (16 << 3)) >> 1;
+}
+
static void clamp_mvs(MACROBLOCKD *xd)
{
if (xd->mbmi.mode == SPLITMV)
@@ -158,11 +171,13 @@
for (i=0; i<16; i++)
clamp_mv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd);
+ for (i=16; i<24; i++)
+ clamp_uvmv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd);
}
else
{
clamp_mv_to_umv_border(&xd->mbmi.mv.as_mv, xd);
- clamp_mv_to_umv_border(&xd->block[16].bmi.mv.as_mv, xd);
+ clamp_uvmv_to_umv_border(&xd->block[16].bmi.mv.as_mv, xd);
}
}