[MPlayer-cvslog] CVS: main/postproc swscale.c, 1.151, 1.152 swscale_template.c, 1.111, 1.112
Ville Syrjälä CVS
syncmail at mplayerhq.hu
Thu Feb 17 00:47:02 CET 2005
- Previous message: [MPlayer-cvslog] CVS: main/libmpcodecs vf.c, 1.110, 1.111 vf_eq.c, 1.8, 1.9 vf_hue.c, 1.3, 1.4 vf_scale.c, 1.56, 1.57 vf_spp.c, 1.26, 1.27
- Next message: [MPlayer-cvslog] CVS: main/libvo vo_dfbmga.c,1.24,1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
CVS change done by Ville Syrjälä CVS
Update of /cvsroot/mplayer/main/postproc
In directory mail:/var2/tmp/cvs-serv10105a/postproc
Modified Files:
swscale.c swscale_template.c
Log Message:
Improved NV12/NV21 support.
- Fixed PlanarToNV12Wrapper() and made it handle NV21.
- Added yuv2nv12XinC() to handle software scaling.
- Added NV12/NV21 handling to various places.
- Removed NV12 from vf_hue and vf_spp as they don't look like they can
actually handle it.
Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -r1.151 -r1.152
--- swscale.c 14 Feb 2005 13:29:55 -0000 1.151
+++ swscale.c 16 Feb 2005 23:46:59 -0000 1.152
@@ -101,6 +101,7 @@
//FIXME replace this with something faster
#define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YVU9 \
+ || (x)==IMGFMT_NV12 || (x)==IMGFMT_NV21 \
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P)
#define isYUV(x) ((x)==IMGFMT_UYVY || (x)==IMGFMT_YUY2 || isPlanarYUV(x))
#define isGray(x) ((x)==IMGFMT_Y800)
@@ -114,6 +115,7 @@
#define isSupportedOut(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P\
|| isRGB(x) || isBGR(x)\
+ || (x)==IMGFMT_NV12 || (x)==IMGFMT_NV21\
|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9)
#define isPacked(x) ((x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY ||isRGB(x) || isBGR(x))
@@ -251,6 +253,56 @@
}
}
+static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
+ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+ uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
+{
+ //FIXME Optimize (just quickly writen not opti..)
+ int i;
+ for(i=0; i<dstW; i++)
+ {
+ int val=1<<18;
+ int j;
+ for(j=0; j<lumFilterSize; j++)
+ val += lumSrc[j][i] * lumFilter[j];
+
+ dest[i]= MIN(MAX(val>>19, 0), 255);
+ }
+
+ if(uDest == NULL)
+ return;
+
+ if(dstFormat == IMGFMT_NV12)
+ for(i=0; i<chrDstW; i++)
+ {
+ int u=1<<18;
+ int v=1<<18;
+ int j;
+ for(j=0; j<chrFilterSize; j++)
+ {
+ u += chrSrc[j][i] * chrFilter[j];
+ v += chrSrc[j][i + 2048] * chrFilter[j];
+ }
+
+ uDest[2*i]= MIN(MAX(u>>19, 0), 255);
+ uDest[2*i+1]= MIN(MAX(v>>19, 0), 255);
+ }
+ else
+ for(i=0; i<chrDstW; i++)
+ {
+ int u=1<<18;
+ int v=1<<18;
+ int j;
+ for(j=0; j<chrFilterSize; j++)
+ {
+ u += chrSrc[j][i] * chrFilter[j];
+ v += chrSrc[j][i + 2048] * chrFilter[j];
+ }
+
+ uDest[2*i]= MIN(MAX(v>>19, 0), 255);
+ uDest[2*i+1]= MIN(MAX(u>>19, 0), 255);
+ }
+}
#define YSCALE_YUV_2_PACKEDX_C(type) \
for(i=0; i<(dstW>>1); i++){\
@@ -1379,13 +1431,16 @@
uint8_t *dstPtr= dst;
for(i=0; i<srcSliceH; i++)
{
- memcpy(dstPtr, srcPtr, srcStride[0]);
+ memcpy(dstPtr, srcPtr, c->srcW);
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
}
}
- dst = dstParam[1] + dstStride[1]*srcSliceY;
- interleaveBytes( src[1],src[2],dst,c->srcW,srcSliceH,srcStride[1],srcStride[2],dstStride[0] );
+ dst = dstParam[1] + dstStride[1]*srcSliceY/2;
+ if (c->dstFormat == IMGFMT_NV12)
+ interleaveBytes( src[1],src[2],dst,c->srcW/2,srcSliceH/2,srcStride[1],srcStride[2],dstStride[0] );
+ else
+ interleaveBytes( src[2],src[1],dst,c->srcW/2,srcSliceH/2,srcStride[2],srcStride[1],dstStride[0] );
return srcSliceH;
}
@@ -1555,6 +1610,15 @@
sortedStride[0]= stride[0];
sortedStride[1]= stride[1];
sortedStride[2]= stride[2];
+ }
+ else if(format == IMGFMT_NV12 || format == IMGFMT_NV21)
+ {
+ sortedP[0]= p[0];
+ sortedP[1]= p[1];
+ sortedP[2]= NULL;
+ sortedStride[0]= stride[0];
+ sortedStride[1]= stride[1];
+ sortedStride[2]= 0;
}else{
MSG_ERR("internal error in orderYUV\n");
}
@@ -1645,6 +1709,8 @@
break;
case IMGFMT_YV12:
case IMGFMT_Y800: //FIXME remove after different subsamplings are fully implemented
+ case IMGFMT_NV12:
+ case IMGFMT_NV21:
*h=1;
*v=1;
break;
@@ -1873,7 +1939,7 @@
if(unscaled && !usesHFilter && !usesVFilter)
{
/* yv12_to_nv12 */
- if(srcFormat == IMGFMT_YV12 && dstFormat == IMGFMT_NV12)
+ if(srcFormat == IMGFMT_YV12 && (dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21))
{
c->swScale= PlanarToNV12Wrapper;
}
Index: swscale_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale_template.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- swscale_template.c 21 Jan 2005 16:48:18 -0000 1.111
+++ swscale_template.c 16 Feb 2005 23:47:00 -0000 1.112
@@ -796,6 +796,15 @@
#endif
}
+static inline void RENAME(yuv2nv12X)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
+ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
+ uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
+{
+yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
+ chrFilter, chrSrc, chrFilterSize,
+ dest, uDest, dstW, chrDstW, dstFormat);
+}
+
static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
@@ -2792,7 +2801,15 @@
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
#endif
- if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like
+ if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
+ RENAME(yuv2nv12X)(c,
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, uDest, dstW, chrDstW, dstFormat);
+ }
+ else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like
{
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
@@ -2840,7 +2857,15 @@
{
int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12
+ if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){
+ const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
+ if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
+ yuv2nv12XinC(
+ vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
+ vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
+ dest, uDest, dstW, chrDstW, dstFormat);
+ }
+ else if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12
{
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
- Previous message: [MPlayer-cvslog] CVS: main/libmpcodecs vf.c, 1.110, 1.111 vf_eq.c, 1.8, 1.9 vf_hue.c, 1.3, 1.4 vf_scale.c, 1.56, 1.57 vf_spp.c, 1.26, 1.27
- Next message: [MPlayer-cvslog] CVS: main/libvo vo_dfbmga.c,1.24,1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list