Commit c42612f1 authored by Michael Niedermayer's avatar Michael Niedermayer

clip MVs for direct mode

Originally committed as revision 1068 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 470ba6f2
...@@ -1336,7 +1336,13 @@ static inline int check_bidir_mv(MpegEncContext * s, ...@@ -1336,7 +1336,13 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
src_x = mb_x * 16 + (motion_fx >> 1); src_x = mb_x * 16 + (motion_fx >> 1);
src_y = mb_y * 16 + (motion_fy >> 1); src_y = mb_y * 16 + (motion_fy >> 1);
src_x = clip(src_x, -16, s->width);
if (src_x == s->width)
dxy&= 2;
src_y = clip(src_y, -16, s->height);
if (src_y == s->height)
dxy&= 1;
ptr = s->last_picture[0] + (src_y * s->linesize) + src_x; ptr = s->last_picture[0] + (src_y * s->linesize) + src_x;
put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
...@@ -1345,6 +1351,12 @@ static inline int check_bidir_mv(MpegEncContext * s, ...@@ -1345,6 +1351,12 @@ static inline int check_bidir_mv(MpegEncContext * s,
dxy = ((motion_by & 1) << 1) | (motion_bx & 1); dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
src_x = mb_x * 16 + (motion_bx >> 1); src_x = mb_x * 16 + (motion_bx >> 1);
src_y = mb_y * 16 + (motion_by >> 1); src_y = mb_y * 16 + (motion_by >> 1);
src_x = clip(src_x, -16, s->width);
if (src_x == s->width)
dxy&= 2;
src_y = clip(src_y, -16, s->height);
if (src_y == s->height)
dxy&= 1;
ptr = s->next_picture[0] + (src_y * s->linesize) + src_x; ptr = s->next_picture[0] + (src_y * s->linesize) + src_x;
avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
......
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