Commit 05c6eca4 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

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.
parent 317a6669
......@@ -149,6 +149,19 @@ static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd)
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)
{
......@@ -158,11 +171,13 @@ static void clamp_mvs(MACROBLOCKD *xd)
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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment