Commit cf1cd520 authored by Ramiro Polla's avatar Ramiro Polla

swscale: factorize plane copying code out of 2 functions

Originally committed as revision 32257 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent f1084cb0
......@@ -1308,24 +1308,33 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
#endif //!CONFIG_RUNTIME_CPUDETECT
}
static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
static void copyPlane(const uint8_t *src, int srcStride,
int srcSliceY, int srcSliceH, int width,
uint8_t *dst, int dstStride)
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
/* Copy Y plane */
if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
memcpy(dst, src[0], srcSliceH*dstStride[0]);
else {
dst += dstStride * srcSliceY;
if (dstStride == srcStride && srcStride > 0) {
memcpy(dst, src, srcSliceH * dstStride);
} else {
int i;
const uint8_t *srcPtr= src[0];
const uint8_t *srcPtr = src;
uint8_t *dstPtr= dst;
for (i=0; i<srcSliceH; i++) {
memcpy(dstPtr, srcPtr, c->srcW);
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
memcpy(dstPtr, srcPtr, width);
srcPtr += srcStride;
dstPtr += dstStride;
}
}
dst = dstParam[1] + dstStride[1]*srcSliceY/2;
}
static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst = dstParam[1] + dstStride[1]*srcSliceY/2;
copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
dstParam[0], dstStride[0]);
if (c->dstFormat == PIX_FMT_NV12)
interleaveBytes(src[1], src[2], dst, c->srcW/2, srcSliceH/2, srcStride[1], srcStride[2], dstStride[0]);
else
......@@ -1583,21 +1592,8 @@ static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride
static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
int i;
/* copy Y */
if (srcStride[0]==dstStride[0] && srcStride[0] > 0)
memcpy(dst[0]+ srcSliceY*dstStride[0], src[0], srcStride[0]*srcSliceH);
else {
const uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
for (i=0; i<srcSliceH; i++) {
memcpy(dstPtr, srcPtr, c->srcW);
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
}
}
copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
dst[0], dstStride[0]);
planar2x(src[1], dst[1] + dstStride[1]*(srcSliceY >> 1), c->chrSrcW,
srcSliceH >> 2, srcStride[1], dstStride[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment