Do planar copy with a single memcpy only if the stride is equal to the length

This avoids writing outside of the designated rectangle.

Originally committed as revision 31756 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
oldabi
Martin Storsjö 15 years ago
parent 9f0e31d29a
commit 72ae5049e1
  1. 6
      libswscale/swscale.c

@ -1663,10 +1663,10 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
} else if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0) {
if (height > 0)
} else if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0 &&
srcStride[plane] == length) {
memcpy(dst[plane] + dstStride[plane]*y, src[plane],
(height - 1)*dstStride[plane] + length);
height*dstStride[plane]);
} else {
if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
length*=2;

Loading…
Cancel
Save