Commit d42c3b56 authored by michael's avatar michael

Merge gray->gray converters into planarCopy(), this should also make planarCopy()

useable for other 16bit formats once we support them.


git-svn-id: file:///var/local/repositories/mplayer/trunk/libswscale@29216 b3059339-0415-0410-9bf9-f77b7e298cf2
parent d029a585
...@@ -2126,102 +2126,63 @@ static int packedCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli ...@@ -2126,102 +2126,63 @@ static int packedCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
static int planarCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int planarCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]) int srcSliceH, uint8_t* dst[], int dstStride[])
{ {
int plane; int plane, i, j;
for (plane=0; plane<4; plane++) for (plane=0; plane<4; plane++)
{ {
int length= (plane==0 || plane==3) ? c->srcW : -((-c->srcW )>>c->chrDstHSubSample); int length= (plane==0 || plane==3) ? c->srcW : -((-c->srcW )>>c->chrDstHSubSample);
int y= (plane==0 || plane==3) ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample); int y= (plane==0 || plane==3) ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
int height= (plane==0 || plane==3) ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample); int height= (plane==0 || plane==3) ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
if (!dst[plane]) continue; if (!dst[plane]) continue;
// ignore palette for GRAY8 // ignore palette for GRAY8
if (plane == 1 && !dst[2]) continue; if (plane == 1 && !dst[2]) continue;
if (!src[plane] || (plane == 1 && !src[2])) if (!src[plane] || (plane == 1 && !src[2])){
if(is16BPS(c->dstFormat))
length*=2;
fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128); fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
else }else
{
if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0)
memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]);
else
{
int i;
uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
for (i=0; i<height; i++)
{ {
memcpy(dstPtr, srcPtr, length); if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)){
if (!isBE(c->srcFormat)) srcPtr++;
for (i=0; i<height; i++){
for (j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];
srcPtr+= srcStride[plane]; srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane]; dstPtr+= dstStride[plane];
} }
}else if(!is16BPS(c->srcFormat) && is16BPS(c->dstFormat)){
for (i=0; i<height; i++){
for (j=0; j<length; j++){
dstPtr[ j<<1 ] = srcPtr[j];
dstPtr[(j<<1)+1] = srcPtr[j];
} }
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
} }
} }else if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat)
return srcSliceH; && isBE(c->srcFormat) != isBE(c->dstFormat)){
}
static int gray16togray(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int length= c->srcW;
int y= srcSliceY;
int height= srcSliceH;
int i, j;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*y;
if (!isGray(c->dstFormat)){ for (i=0; i<height; i++){
int height= -((-srcSliceH)>>c->chrDstVSubSample); for (j=0; j<length; j++)
memset(dst[1], 128, dstStride[1]*height); ((uint16_t*)dstPtr)[j] = bswap_16(((uint16_t*)srcPtr)[j]);
memset(dst[2], 128, dstStride[2]*height); srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
} }
if (!isBE(c->srcFormat)) srcPtr++; } else if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0)
for (i=0; i<height; i++) memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]);
else
{ {
for (j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1]; if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
srcPtr+= srcStride[0]; length*=2;
dstPtr+= dstStride[0];
}
if (dst[3])
fillPlane(dst[3], dstStride[3], length, height, y, 255);
return srcSliceH;
}
static int graytogray16(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int length= c->srcW;
int y= srcSliceY;
int height= srcSliceH;
int i, j;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*y;
for (i=0; i<height; i++) for (i=0; i<height; i++)
{ {
for (j=0; j<length; j++) memcpy(dstPtr, srcPtr, length);
{ srcPtr+= srcStride[plane];
dstPtr[j<<1] = srcPtr[j]; dstPtr+= dstStride[plane];
dstPtr[(j<<1)+1] = srcPtr[j]; }
} }
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
} }
return srcSliceH;
}
static int gray16swap(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int length= c->srcW;
int y= srcSliceY;
int height= srcSliceH;
int i, j;
uint16_t *srcPtr= (uint16_t*)src[0];
uint16_t *dstPtr= (uint16_t*)(dst[0] + dstStride[0]*y/2);
for (i=0; i<height; i++)
{
for (j=0; j<length; j++) dstPtr[j] = bswap_16(srcPtr[j]);
srcPtr+= srcStride[0]/2;
dstPtr+= dstStride[0]/2;
} }
return srcSliceH; return srcSliceH;
} }
...@@ -2612,28 +2573,14 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d ...@@ -2612,28 +2573,14 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
|| (srcFormat == PIX_FMT_YUVA420P && dstFormat == PIX_FMT_YUV420P) || (srcFormat == PIX_FMT_YUVA420P && dstFormat == PIX_FMT_YUV420P)
|| (srcFormat == PIX_FMT_YUV420P && dstFormat == PIX_FMT_YUVA420P) || (srcFormat == PIX_FMT_YUV420P && dstFormat == PIX_FMT_YUVA420P)
|| (isPlanarYUV(srcFormat) && isGray(dstFormat)) || (isPlanarYUV(srcFormat) && isGray(dstFormat))
|| (isPlanarYUV(dstFormat) && isGray(srcFormat))) || (isPlanarYUV(dstFormat) && isGray(srcFormat))
|| (isGray(dstFormat) && isGray(srcFormat)))
{ {
if (isPacked(c->srcFormat)) if (isPacked(c->srcFormat))
c->swScale= packedCopy; c->swScale= packedCopy;
else /* Planar YUV or gray */ else /* Planar YUV or gray */
c->swScale= planarCopy; c->swScale= planarCopy;
} }
/* gray16{le,be} conversions */
if (isGray16(srcFormat) && (isPlanarYUV(dstFormat) || (dstFormat == PIX_FMT_GRAY8)))
{
c->swScale= gray16togray;
}
if ((isPlanarYUV(srcFormat) || (srcFormat == PIX_FMT_GRAY8)) && isGray16(dstFormat))
{
c->swScale= graytogray16;
}
if (srcFormat != dstFormat && isGray16(srcFormat) && isGray16(dstFormat))
{
c->swScale= gray16swap;
}
#if ARCH_BFIN #if ARCH_BFIN
if (flags & SWS_CPU_CAPS_BFIN) if (flags & SWS_CPU_CAPS_BFIN)
ff_bfin_get_unscaled_swscale (c); ff_bfin_get_unscaled_swscale (c);
......
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