diff options
Diffstat (limited to 'vp8/common')
-rw-r--r-- | vp8/common/findnearmv.c | 42 | ||||
-rw-r--r-- | vp8/common/findnearmv.h | 39 |
2 files changed, 38 insertions, 43 deletions
diff --git a/vp8/common/findnearmv.c b/vp8/common/findnearmv.c index e63d4ef8d..cab0403f1 100644 --- a/vp8/common/findnearmv.c +++ b/vp8/common/findnearmv.c @@ -16,42 +16,6 @@ /* Predict motion vectors using those from already-decoded nearby blocks. Note that we only consider one 4x4 subblock from each candidate 16x16 macroblock. */ - -typedef union -{ - unsigned int as_int; - MV as_mv; -} int_mv; /* facilitates rapid equality tests */ - -static void mv_bias(const MODE_INFO *x, int refframe, int_mv *mvp, const int *ref_frame_sign_bias) -{ - MV xmv; - xmv = x->mbmi.mv.as_mv; - - if (ref_frame_sign_bias[x->mbmi.ref_frame] != ref_frame_sign_bias[refframe]) - { - xmv.row *= -1; - xmv.col *= -1; - } - - mvp->as_mv = xmv; -} - - -void vp8_clamp_mv(MV *mv, const MACROBLOCKD *xd) -{ - if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN)) - mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN; - else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN) - mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN; - - if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN)) - mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN; - else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN) - mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN; -} - - void vp8_find_near_mvs ( MACROBLOCKD *xd, @@ -82,7 +46,7 @@ void vp8_find_near_mvs if (above->mbmi.mv.as_int) { (++mv)->as_int = above->mbmi.mv.as_int; - mv_bias(above, refframe, mv, ref_frame_sign_bias); + mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame], refframe, mv, ref_frame_sign_bias); ++cntx; } @@ -97,7 +61,7 @@ void vp8_find_near_mvs int_mv this_mv; this_mv.as_int = left->mbmi.mv.as_int; - mv_bias(left, refframe, &this_mv, ref_frame_sign_bias); + mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame], refframe, &this_mv, ref_frame_sign_bias); if (this_mv.as_int != mv->as_int) { @@ -119,7 +83,7 @@ void vp8_find_near_mvs int_mv this_mv; this_mv.as_int = aboveleft->mbmi.mv.as_int; - mv_bias(aboveleft, refframe, &this_mv, ref_frame_sign_bias); + mv_bias(ref_frame_sign_bias[aboveleft->mbmi.ref_frame], refframe, &this_mv, ref_frame_sign_bias); if (this_mv.as_int != mv->as_int) { diff --git a/vp8/common/findnearmv.h b/vp8/common/findnearmv.h index 1a6c72bcd..cb5a58e1a 100644 --- a/vp8/common/findnearmv.h +++ b/vp8/common/findnearmv.h @@ -17,6 +17,41 @@ #include "modecont.h" #include "treecoder.h" +typedef union +{ + unsigned int as_int; + MV as_mv; +} int_mv; /* facilitates rapid equality tests */ + +static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, const int *ref_frame_sign_bias) +{ + MV xmv; + xmv = mvp->as_mv; + + if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe]) + { + xmv.row *= -1; + xmv.col *= -1; + } + + mvp->as_mv = xmv; +} + +#define LEFT_TOP_MARGIN (16 << 3) +#define RIGHT_BOTTOM_MARGIN (16 << 3) +static void vp8_clamp_mv(MV *mv, const MACROBLOCKD *xd) +{ + if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN)) + mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN; + else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN) + mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN; + + if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN)) + mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN; + else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN) + mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN; +} + void vp8_find_near_mvs ( MACROBLOCKD *xd, @@ -35,8 +70,4 @@ const B_MODE_INFO *vp8_left_bmi(const MODE_INFO *cur_mb, int b); const B_MODE_INFO *vp8_above_bmi(const MODE_INFO *cur_mb, int b, int mi_stride); -#define LEFT_TOP_MARGIN (16 << 3) -#define RIGHT_BOTTOM_MARGIN (16 << 3) - - #endif |