[Mplayer-cvslog] CVS: main/postproc swscale.c,1.96,1.97 swscale_template.c,1.82,1.83 swscale.h,1.17,1.18

Michael Niedermayer michael at mplayerhq.hu
Mon Jun 24 02:18:32 CEST 2002


Update of /cvsroot/mplayer/main/postproc
In directory mail:/var/tmp.root/cvs-serv28163

Modified Files:
	swscale.c swscale_template.c swscale.h 
Log Message:

100l (non mmx versions didnt compile)
some cleanup


Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- swscale.c	23 Jun 2002 19:30:35 -0000	1.96
+++ swscale.c	24 Jun 2002 00:18:29 -0000	1.97
@@ -253,6 +253,8 @@
              int srcSliceH, uint8_t* dst[], int dstStride[])=NULL;
 
 static SwsVector *getConvVec(SwsVector *a, SwsVector *b);
+static inline void orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]);
+
 
 #ifdef CAN_COMPILE_X86_ASM
 void in_asm_used_var_warning_killer()
@@ -383,13 +385,13 @@
 	}
 }
 
-static inline void yuv2yuvXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
+static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
 				    int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-				    uint8_t *dest, uint8_t *uDest, uint8_t *vDest)
+				    uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
 {
 	//FIXME Optimize (just quickly writen not opti..)
 	int i;
-	for(i=0; i<c->dstW; i++)
+	for(i=0; i<dstW; i++)
 	{
 		int val=0;
 		int j;
@@ -400,7 +402,7 @@
 	}
 
 	if(uDest != NULL)
-		for(i=0; i<c->chrDstW; i++)
+		for(i=0; i<chrDstW; i++)
 		{
 			int u=0;
 			int v=0;
@@ -733,11 +735,10 @@
 	context->swScale(context, src, srcStride, srcSliceY, srcSliceH, dst, dstStride3);
 }
 
-// will use sws_flags & src_filter (from cmd line)
-SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat)
+void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam)
 {
-	int flags=0;
 	static int firstTime=1;
+	*flags=0;
 
 #ifdef ARCH_X86
 	if(gCpuCaps.hasMMX)
@@ -746,9 +747,9 @@
 	if(firstTime)
 	{
 		firstTime=0;
-		flags= SWS_PRINT_INFO;
+		*flags= SWS_PRINT_INFO;
 	}
-	else if(verbose>1) flags= SWS_PRINT_INFO;
+	else if(verbose>1) *flags= SWS_PRINT_INFO;
 
 	if(src_filter.lumH) freeVec(src_filter.lumH);
 	if(src_filter.lumV) freeVec(src_filter.lumV);
@@ -809,16 +810,27 @@
 
 	switch(sws_flags)
 	{
-		case 0: flags|= SWS_FAST_BILINEAR; break;
-		case 1: flags|= SWS_BILINEAR; break;
-		case 2: flags|= SWS_BICUBIC; break;
-		case 3: flags|= SWS_X; break;
-		case 4: flags|= SWS_POINT; break;
-		case 5: flags|= SWS_AREA; break;
-		default:flags|= SWS_BILINEAR; break;
+		case 0: *flags|= SWS_FAST_BILINEAR; break;
+		case 1: *flags|= SWS_BILINEAR; break;
+		case 2: *flags|= SWS_BICUBIC; break;
+		case 3: *flags|= SWS_X; break;
+		case 4: *flags|= SWS_POINT; break;
+		case 5: *flags|= SWS_AREA; break;
+		default:*flags|= SWS_BILINEAR; break;
 	}
+	
+	*srcFilterParam= &src_filter;
+	*dstFilterParam= NULL;
+}
+
+// will use sws_flags & src_filter (from cmd line)
+SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat)
+{
+	int flags;
+	SwsFilter *dstFilterParam, *srcFilterParam;
+	swsGetFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam);
 
-	return getSwsContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, &src_filter, NULL);
+	return getSwsContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, srcFilterParam, dstFilterParam);
 }
 
 
@@ -1863,11 +1875,11 @@
 	// reuse chroma for 2 pixles rgb/bgr unless user wants full chroma interpolation
 	if((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
 
-	// drop eery 2. pixel for chroma calculation unless user wants full chroma
-	if((isBGR(srcFormat) || isRGB(srcFormat) || srcFormat==IMGFMT_YUY2) && !(flags&SWS_FULL_CHR_V)) 
-		c->chrSrcVSubSample=1;
+	// drop some chroma lines if the user wants it
+	c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
+	c->chrSrcVSubSample+= c->vChrDrop;
 
-	// drop eery 2. pixel for chroma calculation unless user wants full chroma
+	// drop every 2. pixel for chroma calculation unless user wants full chroma
 	if((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP)) 
 		c->chrSrcHSubSample=1;
 

Index: swscale_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale_template.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- swscale_template.c	23 Jun 2002 18:51:43 -0000	1.82
+++ swscale_template.c	24 Jun 2002 00:18:29 -0000	1.83
@@ -683,9 +683,9 @@
 			: "%eax", "%edx", "%esi"
 		);
 #else
-yuv2yuvXinC(c, lumFilter, lumSrc, lumFilterSize,
+yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
 	    chrFilter, chrSrc, chrFilterSize,
-	    dest, uDest, vDest);
+	    dest, uDest, vDest, dstW, chrDstW);
 #endif
 }
 
@@ -2623,56 +2623,21 @@
 	int dstStride[3];
 	uint8_t *src[3];
 	uint8_t *dst[3];
+	
+	orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam);
+	orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam);
 
-	if(c->srcFormat == IMGFMT_I420){
-		src[0]= srcParam[0];
-		src[1]= srcParam[2];
-		src[2]= srcParam[1];
-		srcStride[0]= srcStrideParam[0];
-		srcStride[1]= srcStrideParam[2];
-		srcStride[2]= srcStrideParam[1];
-	}
-	else if(c->srcFormat==IMGFMT_YV12 || c->srcFormat==IMGFMT_YVU9){
-		src[0]= srcParam[0];
-		src[1]= srcParam[1];
-		src[2]= srcParam[2];
-		srcStride[0]= srcStrideParam[0];
-		srcStride[1]= srcStrideParam[1];
-		srcStride[2]= srcStrideParam[2];
-	}
-	else if(isPacked(c->srcFormat)){
+	if(isPacked(c->srcFormat)){
 		src[0]=
 		src[1]=
 		src[2]= srcParam[0];
-		srcStride[0]= srcStrideParam[0];
+		srcStride[0]=
 		srcStride[1]=
-		srcStride[2]= srcStrideParam[0]<<1;
-	}
-	else if(isGray(c->srcFormat)){
-		src[0]= srcParam[0];
-		src[1]=
-		src[2]= NULL;
-		srcStride[0]= srcStrideParam[0];
-		srcStride[1]=
-		srcStride[2]= 0;
+		srcStride[2]= srcStrideParam[0];
 	}
+	srcStride[1]<<= c->vChrDrop;
+	srcStride[2]<<= c->vChrDrop;
 
-	if(dstFormat == IMGFMT_I420){
-		dst[0]= dstParam[0];
-		dst[1]= dstParam[2];
-		dst[2]= dstParam[1];
-		dstStride[0]= dstStrideParam[0];
-		dstStride[1]= dstStrideParam[2];
-		dstStride[2]= dstStrideParam[1];
-	}else{
-		dst[0]= dstParam[0];
-		dst[1]= dstParam[1];
-		dst[2]= dstParam[2];
-		dstStride[0]= dstStrideParam[0];
-		dstStride[1]= dstStrideParam[1];
-		dstStride[2]= dstStrideParam[2];
-	}
-	
 //	printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2],
 //		(int)dst[0], (int)dst[1], (int)dst[2]);
 
@@ -2878,10 +2843,10 @@
 		if(isPlanarYUV(dstFormat)) //YV12
 		{
 			if(dstY&1) uDest=vDest= NULL;
-			yuv2yuvXinC(c, 
+			yuv2yuvXinC(
 				vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
 				vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-				dest, uDest, vDest);
+				dest, uDest, vDest, dstW, chrDstW);
 		}
 		else
 		{

Index: swscale.h
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- swscale.h	23 Jun 2002 10:36:18 -0000	1.17
+++ swscale.h	24 Jun 2002 00:18:29 -0000	1.18
@@ -24,9 +24,11 @@
 #define SWS_POINT    0x10
 #define SWS_AREA     0x20
 
+#define SWS_SRC_V_CHR_DROP_MASK		0x300
+#define SWS_SRC_V_CHR_DROP_SHIFT	8
+
 //the following 4 flags are not completly implemented
 //internal chrominace subsamling info
-#define SWS_FULL_CHR_V		0x100
 #define SWS_FULL_CHR_H_INT	0x200
 //input subsampling info
 #define SWS_FULL_CHR_H_INP	0x400
@@ -46,6 +48,7 @@
 	int chrSrcHSubSample, chrSrcVSubSample;
 	int chrIntHSubSample, chrIntVSubSample;
 	int chrDstHSubSample, chrDstVSubSample;
+	int vChrDrop;
 
 	int16_t **lumPixBuf;
 	int16_t **chrPixBuf;
@@ -125,6 +128,7 @@
 SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
 SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
 			 SwsFilter *srcFilter, SwsFilter *dstFilter);
+void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
 
 SwsVector *getGaussianVec(double variance, double quality);
 SwsVector *getConstVec(double c, int length);




More information about the MPlayer-cvslog mailing list