summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libmpeg2/slice.c16
1 files changed, 12 insertions, 4 deletions
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, \