# HG changeset patch # User kostya # Date 1225346927 0 # Node ID ae146e4290034361964b0fa7bed704b6a4f90449 # Parent 17b40776c5ce2a37b11a77202a75ca5c0dcec6f7 Correct motion vector scaling in B-frames for RV3/4 diff -r 17b40776c5ce -r ae146e429003 rv34.c --- a/rv34.c Wed Oct 29 23:44:40 2008 +0000 +++ b/rv34.c Thu Oct 30 06:08:47 2008 +0000 @@ -474,13 +474,12 @@ static int calc_add_mv(RV34DecContext *r, int dir, int val) { int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); - int dist = dir ? GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts); + int dist = dir ? -GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts); + int mul; if(!refdist) return 0; - if(!dir) - return (val * dist + refdist - 1) / refdist; - else - return -(val * dist / refdist); + mul = (dist << 14) / refdist; + return (val * mul + 0x2000) >> 14; } /**