changeset 765:7f0d502a42c5 libavcodec

clip MVs for direct mode
author michaelni
date Thu, 24 Oct 2002 00:51:17 +0000
parents d4726182dfd2
children 8d36b35a7e6e
files motion_est.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/motion_est.c	Wed Oct 23 15:11:07 2002 +0000
+++ b/motion_est.c	Thu Oct 24 00:51:17 2002 +0000
@@ -1336,7 +1336,13 @@
     dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
     src_x = mb_x * 16 + (motion_fx >> 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;
     put_pixels_tab[0][dxy](dest_y    , ptr    , s->linesize, 16);
     
@@ -1345,6 +1351,12 @@
     dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
     src_x = mb_x * 16 + (motion_bx >> 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;
     avg_pixels_tab[0][dxy](dest_y    , ptr    , s->linesize, 16);