OSDN Git Service

Merge commit '25a6666f6c07c6ac8449a63d7fbce0dfd29c54cd'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 15 Jul 2013 10:45:32 +0000 (12:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 15 Jul 2013 11:13:52 +0000 (13:13 +0200)
* commit '25a6666f6c07c6ac8449a63d7fbce0dfd29c54cd':
  indeo: Bound-check before applying motion compensation

The added checks and one previously added check are replaced by asserts,
the conditions can only be
true when vectors are invalid or there are worse inconsistencies.
We are checking the vectors validity and there should be no
inconsistencies, thus the checks should not be needed.
Also no files are known to cause any anomalies in ffmpeg

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/ivi_common.c

@@@ -44,16 -44,22 +44,19 @@@ static VLC ivi_blk_vlc_tabs[8]; ///< st
  typedef void (*ivi_mc_func) (int16_t *buf, const int16_t *ref_buf,
                               uint32_t pitch, int mc_type);
  
- static int ivi_mc(ivi_mc_func mc, int16_t *buf, const int16_t *ref_buf,
-                   int offs, int mv_x, int mv_y, uint32_t pitch,
-                   int mc_type)
+ static int ivi_mc(IVIBandDesc *band, ivi_mc_func mc,
+                   int offs, int mv_x, int mv_y, int mc_type)
  {
-     int ref_offs = offs + mv_y * pitch + mv_x;
+     int ref_offs = offs + mv_y * band->pitch + mv_x;
+     int buf_size = band->pitch * band->aheight;
+     int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
+     int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
  
-     if (offs < 0 || ref_offs < 0 || !ref_buf)
 -    if (offs < 0 || ref_offs < 0 || !band->ref_buf)
 -        return AVERROR_INVALIDDATA;
 -    if (buf_size - min_size < offs)
 -        return AVERROR_INVALIDDATA;
 -    if (buf_size - min_size - ref_size < ref_offs)
--        return AVERROR_INVALIDDATA;
++    av_assert0(offs >= 0 && ref_offs >= 0 && band->ref_buf);
++    av_assert0(buf_size - min_size >= offs);
++    av_assert0(buf_size - min_size - ref_size >= ref_offs);
  
-     mc(buf + offs, ref_buf + ref_offs, pitch, mc_type);
+     mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
  
      return 0;
  }