comparison rv34.c @ 8086:ae146e429003 libavcodec

Correct motion vector scaling in B-frames for RV3/4
author kostya
date Thu, 30 Oct 2008 06:08:47 +0000
parents 31e90d4abe28
children bc786a34f6eb
comparison
equal deleted inserted replaced
8085:17b40776c5ce 8086:ae146e429003
472 * Calculate motion vector component that should be added for direct blocks. 472 * Calculate motion vector component that should be added for direct blocks.
473 */ 473 */
474 static int calc_add_mv(RV34DecContext *r, int dir, int val) 474 static int calc_add_mv(RV34DecContext *r, int dir, int val)
475 { 475 {
476 int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); 476 int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
477 int dist = dir ? GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts); 477 int dist = dir ? -GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts);
478 int mul;
478 479
479 if(!refdist) return 0; 480 if(!refdist) return 0;
480 if(!dir) 481 mul = (dist << 14) / refdist;
481 return (val * dist + refdist - 1) / refdist; 482 return (val * mul + 0x2000) >> 14;
482 else
483 return -(val * dist / refdist);
484 } 483 }
485 484
486 /** 485 /**
487 * Predict motion vector for B-frame macroblock. 486 * Predict motion vector for B-frame macroblock.
488 */ 487 */