[FFmpeg-cvslog] motion_est: Limit motion vector search range to MAX_MV
Michael Niedermayer
git at videolan.org
Wed Jan 16 06:07:26 CET 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jan 16 05:54:19 2013 +0100| [bbe56bcd6befb3e7d1bd498d8b827325d6089d78] | committer: Michael Niedermayer
motion_est: Limit motion vector search range to MAX_MV
Fixes out of array reads with videos exceeding MAX_MV
Found-by: Thierry Foucu
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbe56bcd6befb3e7d1bd498d8b827325d6089d78
---
libavcodec/motion_est.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index a303d37..2c16c9a 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -516,6 +516,7 @@ static inline void get_limits(MpegEncContext *s, int x, int y)
{
MotionEstContext * const c= &s->me;
int range= c->avctx->me_range >> (1 + !!(c->flags&FLAG_QPEL));
+ int max_range = MAX_MV >> (1 + !!(c->flags&FLAG_QPEL));
/*
if(c->avctx->me_range) c->range= c->avctx->me_range >> 1;
else c->range= 16;
@@ -537,6 +538,8 @@ static inline void get_limits(MpegEncContext *s, int x, int y)
c->xmax = - x + s->mb_width *16 - 16;
c->ymax = - y + s->mb_height*16 - 16;
}
+ if(!range || range > max_range)
+ range = max_range;
if(range){
c->xmin = FFMAX(c->xmin,-range);
c->xmax = FFMIN(c->xmax, range);
More information about the ffmpeg-cvslog
mailing list