From ab46a84ba585cf2644642e6cf491beca0ecaac56 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Thu, 9 Jan 2003 19:15:15 +0000 Subject: patch from walken to clip motion vectors. fix playback for some streams. CVS patchset: 3847 CVS date: 2003/01/09 19:15:15 --- src/libmpeg2/slice.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libmpeg2/slice.c b/src/libmpeg2/slice.c index b190acdd6..7739ef067 100644 --- a/src/libmpeg2/slice.c +++ b/src/libmpeg2/slice.c @@ -993,8 +993,12 @@ static inline void slice_non_intra_DCT (picture_t * picture, uint8_t * dest, #define MOTION(table,ref,motion_x,motion_y,size,y) \ pos_x = 2 * picture->offset + motion_x; \ pos_y = 2 * picture->v_offset + motion_y + 2 * y; \ - if ((pos_x > picture->limit_x) || (pos_y > picture->limit_y_ ## size)) \ - return; \ + if ((pos_x > picture->limit_x) || (pos_y > picture->limit_y_ ## size)) { \ + if (pos_x > picture->limit_x) \ + pos_x = (((int)pos_x) < 0) ? 0 : picture->limit_x; \ + if (pos_y > picture->limit_y_ ## size) \ + pos_y = (((int)pos_y) < 0) ? 0 : picture->limit_y_ ## size; \ + } \ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \ table[xy_half] (picture->dest[0] + y * picture->pitches[0] + \ picture->offset, ref[0] + (pos_x >> 1) + \ @@ -1016,8 +1020,12 @@ static inline void slice_non_intra_DCT (picture_t * picture, uint8_t * dest, #define MOTION_FIELD(table,ref,motion_x,motion_y,dest_field,op,src_field) \ pos_x = 2 * picture->offset + motion_x; \ pos_y = picture->v_offset + motion_y; \ - if ((pos_x > picture->limit_x) || (pos_y > picture->limit_y)) \ - return; \ + if ((pos_x > picture->limit_x) || (pos_y > picture->limit_y)) { \ + if (pos_x > picture->limit_x) \ + pos_x = (((int)pos_x) < 0) ? 0 : picture->limit_x; \ + if (pos_y > picture->limit_y) \ + pos_y = (((int)pos_y) < 0) ? 0 : picture->limit_y; \ + } \ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \ table[xy_half] (picture->dest[0] + dest_field * picture->pitches[0] + \ picture->offset, \ -- cgit v1.2.3