[Mplayer-cvslog] CVS: main/postproc swscale.c,1.60,1.61 swscale.h,1.11,1.12

Michael Niedermayer michael at mplayer.dev.hu
Tue Jan 29 02:43:27 CET 2002


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

Modified Files:
	swscale.c swscale.h 
Log Message:
area averageing scaling support (-sws 5) (is identical to bilinear for upscale)


Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- swscale.c	28 Jan 2002 23:57:18 -0000	1.60
+++ swscale.c	29 Jan 2002 01:43:15 -0000	1.61
@@ -604,6 +604,7 @@
 		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;
 	}
 
@@ -666,7 +667,7 @@
 		int xDstInSrc;
 		if     (flags&SWS_BICUBIC) filterSize= 4;
 		else if(flags&SWS_X      ) filterSize= 4;
-		else			   filterSize= 2;
+		else			   filterSize= 2; // SWS_BILINEAR / SWS_AREA 
 //		printf("%d %d %d\n", filterSize, srcW, dstW);
 		filter= (double*)memalign(8, dstW*sizeof(double)*filterSize);
 
@@ -705,6 +706,7 @@
 			}
 			else
 			{
+				//Bilinear upscale / linear interpolate / Area averaging
 				for(j=0; j<filterSize; j++)
 				{
 					double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16);
@@ -721,9 +723,10 @@
 	else // downscale
 	{
 		int xDstInSrc;
-		if(flags&SWS_BICUBIC) filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);
-		else if(flags&SWS_X)  filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);
-		else		      filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);
+		if(flags&SWS_BICUBIC)	filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);
+		else if(flags&SWS_X)	filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);
+		else if(flags&SWS_AREA)	filterSize= (int)ceil(1 + 1.0*srcW / (double)dstW);
+		else /* BILINEAR */	filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);
 //		printf("%d %d %d\n", *filterSize, srcW, dstW);
 		filter= (double*)memalign(8, dstW*sizeof(double)*filterSize);
 
@@ -749,15 +752,19 @@
 					else
 						coeff=0.0;
 				}
-/*				else if(flags & SWS_X)
+				else if(flags & SWS_AREA)
 				{
-				}*/
+					double srcPixelSize= (1<<16)/(double)xInc;
+					if(d + srcPixelSize/2 < 0.5) coeff= 1.0;
+					else if(d - srcPixelSize/2 < 0.5) coeff= (0.5-d)/srcPixelSize + 0.5;
+					else coeff=0.0;
+				}
 				else
 				{
 					coeff= 1.0 - d;
 					if(coeff<0) coeff=0;
 				}
-//				printf("%1.3f %d %d \n", coeff, (int)d, xDstInSrc);
+//				printf("%1.3f %2.3f %d \n", coeff, d, xDstInSrc);
 				filter[i*filterSize + j]= coeff;
 				xx++;
 			}
@@ -1225,7 +1232,9 @@
 		else if(flags&SWS_BICUBIC)
 			fprintf(stderr, "\nSwScaler: BICUBIC scaler ");
 		else if(flags&SWS_POINT)
-			fprintf(stderr, "\nSwScaler: POINT scaler ");
+			fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler ");
+		else if(flags&SWS_AREA)
+			fprintf(stderr, "\nSwScaler: Area Averageing scaler ");
 		else
 			fprintf(stderr, "\nSwScaler: ehh flags invalid?! ");
 

Index: swscale.h
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- swscale.h	28 Jan 2002 23:57:18 -0000	1.11
+++ swscale.h	29 Jan 2002 01:43:15 -0000	1.12
@@ -22,6 +22,7 @@
 #define SWS_BICUBIC  4
 #define SWS_X        8
 #define SWS_POINT    0x10
+#define SWS_AREA     0x20
 #define SWS_FULL_UV_IPOL 0x100
 #define SWS_PRINT_INFO 0x1000
 




More information about the MPlayer-cvslog mailing list