static inline void RENAME(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc,

				      int srcW, int dstW, int filterAlign, int one)

{

	int i;

	double filter[8000];

#ifdef HAVE_MMX

	asm volatile("emms\n\t"::: "memory"); //FIXME this shouldnt be required but it IS (even for non mmx versions)

#endif



	if(ABS(xInc - 0x10000) <10) // unscaled

	{

		int i;

		*filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); // 1 or 4 normaly

		for(i=0; i<dstW*(*filterSize); i++) filter[i]=0;



		for(i=0; i<dstW; i++)

		{

			filter[i*(*filterSize)]=1;

			filterPos[i]=i;

		}



	}

	else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR) // upscale

	{

		int i;

		int xDstInSrc;

		if(sws_flags==SWS_BICUBIC) *filterSize= 4;

		else			   *filterSize= 2;

//		printf("%d %d %d\n", filterSize, srcW, dstW);

		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		xDstInSrc= xInc/2 - 0x8000;

		for(i=0; i<dstW; i++)

		{

			int xx= (xDstInSrc>>16) - (*filterSize>>1) + 1;

			int j;



			filterPos[i]= xx;

			if(sws_flags == SWS_BICUBIC)

			{

				double d= ABS(((xx+1)<<16) - xDstInSrc)/(double)(1<<16);

				double y1,y2,y3,y4;

				double A= -0.75;

					// Equation is from VirtualDub

				y1 = (        +     A*d -       2.0*A*d*d +       A*d*d*d);

				y2 = (+ 1.0             -     (A+3.0)*d*d + (A+2.0)*d*d*d);

				y3 = (        -     A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d);

				y4 = (                  +           A*d*d -       A*d*d*d);



//				printf("%d %d %d \n", coeff, (int)d, xDstInSrc);

				filter[i*(*filterSize) + 0]= y1;

				filter[i*(*filterSize) + 1]= y2;

				filter[i*(*filterSize) + 2]= y3;

				filter[i*(*filterSize) + 3]= y4;

//				printf("%1.3f %d, %d, %d, %d\n",d , y1, y2, y3, y4);

			}

			else

			{

				for(j=0; j<*filterSize; j++)

				{

					double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16);

					double coeff= 1.0 - d;

					if(coeff<0) coeff=0;

	//				printf("%d %d %d \n", coeff, (int)d, xDstInSrc);

					filter[i*(*filterSize) + j]= coeff;

					xx++;

				}

			}

			xDstInSrc+= xInc;

		}

	}

	else // downscale

	{

		int xDstInSrc;

		if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);

		else			   *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);

//		printf("%d %d %d\n", *filterSize, srcW, dstW);

		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		xDstInSrc= xInc/2 - 0x8000;

		for(i=0; i<dstW; i++)

		{

			int xx= (int)((double)xDstInSrc/(double)(1<<16) - ((*filterSize)-1)*0.5 + 0.5);

			int j;



			filterPos[i]= xx;

			for(j=0; j<*filterSize; j++)

			{

				double d= ABS((xx<<16) - xDstInSrc)/(double)xInc;

				double coeff;

				if(sws_flags == SWS_BICUBIC)

				{

					double A= -0.75;

//					d*=2;

					// Equation is from VirtualDub

					if(d<1.0)

						coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d);

					else if(d<2.0)

						coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d);

					else

						coeff=0.0;

				}

				else

				{

					coeff= 1.0 - d;

					if(coeff<0) coeff=0;

				}

//				if(filterAlign==1) printf("%d %d %d \n", coeff, (int)d, xDstInSrc);

				filter[i*(*filterSize) + j]= coeff;

				xx++;

			}

			xDstInSrc+= xInc;

		}

	}



	//fix borders

	for(i=0; i<dstW; i++)

	{

		int j;

		if(filterPos[i] < 0)

		{

			// Move filter coeffs left to compensate for filterPos

			for(j=1; j<*filterSize; j++)

			{

				int left= MAX(j + filterPos[i], 0);

				filter[i*(*filterSize) + left] += filter[i*(*filterSize) + j];

				filter[i*(*filterSize) + j]=0;

			}

			filterPos[i]= 0;

		}



		if(filterPos[i] + (*filterSize) > srcW)

		{

			int shift= filterPos[i] + (*filterSize) - srcW;

			// Move filter coeffs right to compensate for filterPos

			for(j=(*filterSize)-2; j>=0; j--)

			{

				int right= MIN(j + shift, (*filterSize)-1);

				filter[i*(*filterSize) +right] += filter[i*(*filterSize) +j];

				filter[i*(*filterSize) +j]=0;

			}

			filterPos[i]= srcW - (*filterSize);

		}

	}



	//FIXME try to align filterpos if possible / try to shift filterpos to put zeros at the end

	// and skip these than later



	//Normalize

	for(i=0; i<dstW; i++)

	{

		int j;

		double sum=0;

		double scale= one;

		for(j=0; j<*filterSize; j++)

		{

			sum+= filter[i*(*filterSize) + j];

		}

		scale/= sum;

		for(j=0; j<*filterSize; j++)

		{

			dstFilter[i*(*filterSize) + j]= (int)(filter[i*(*filterSize) + j]*scale);

		}

	}

}

static inline void RENAME(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc,

				      int srcW, int dstW, int filterAlign, int one)

{

	int i;

	double filter[8000];

#ifdef HAVE_MMX

	asm volatile("emms\n\t"::: "memory"); 

#endif



	if(ABS(xInc - 0x10000) <10) 

	{

		int i;

		*filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); 

		for(i=0; i<dstW*(*filterSize); i++) filter[i]=0;



		for(i=0; i<dstW; i++)

		{

			filter[i*(*filterSize)]=1;

			filterPos[i]=i;

		}



	}

	else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR) 

	{

		int i;

		int xDstInSrc;

		if(sws_flags==SWS_BICUBIC) *filterSize= 4;

		else			   *filterSize= 2;



		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		xDstInSrc= xInc/2 - 0x8000;

		for(i=0; i<dstW; i++)

		{

			int xx= (xDstInSrc>>16) - (*filterSize>>1) + 1;

			int j;



			filterPos[i]= xx;

			if(sws_flags == SWS_BICUBIC)

			{

				double d= ABS(((xx+1)<<16) - xDstInSrc)/(double)(1<<16);

				double y1,y2,y3,y4;

				double A= -0.75;

					

				y1 = (        +     A*d -       2.0*A*d*d +       A*d*d*d);

				y2 = (+ 1.0             -     (A+3.0)*d*d + (A+2.0)*d*d*d);

				y3 = (        -     A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d);

				y4 = (                  +           A*d*d -       A*d*d*d);





				filter[i*(*filterSize) + 0]= y1;

				filter[i*(*filterSize) + 1]= y2;

				filter[i*(*filterSize) + 2]= y3;

				filter[i*(*filterSize) + 3]= y4;



			}

			else

			{

				for(j=0; j<*filterSize; j++)

				{

					double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16);

					double coeff= 1.0 - d;

					if(coeff<0) coeff=0;

	

					filter[i*(*filterSize) + j]= coeff;

					xx++;

				}

			}

			xDstInSrc+= xInc;

		}

	}

	else 

	{

		int xDstInSrc;

		if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);

		else			   *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);



		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		xDstInSrc= xInc/2 - 0x8000;

		for(i=0; i<dstW; i++)

		{

			int xx= (int)((double)xDstInSrc/(double)(1<<16) - ((*filterSize)-1)*0.5 + 0.5);

			int j;



			filterPos[i]= xx;

			for(j=0; j<*filterSize; j++)

			{

				double d= ABS((xx<<16) - xDstInSrc)/(double)xInc;

				double coeff;

				if(sws_flags == SWS_BICUBIC)

				{

					double A= -0.75;



					

					if(d<1.0)

						coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d);

					else if(d<2.0)

						coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d);

					else

						coeff=0.0;

				}

				else

				{

					coeff= 1.0 - d;

					if(coeff<0) coeff=0;

				}



				filter[i*(*filterSize) + j]= coeff;

				xx++;

			}

			xDstInSrc+= xInc;

		}

	}



	

	for(i=0; i<dstW; i++)

	{

		int j;

		if(filterPos[i] < 0)

		{

			

			for(j=1; j<*filterSize; j++)

			{

				int left= MAX(j + filterPos[i], 0);

				filter[i*(*filterSize) + left] += filter[i*(*filterSize) + j];

				filter[i*(*filterSize) + j]=0;

			}

			filterPos[i]= 0;

		}



		if(filterPos[i] + (*filterSize) > srcW)

		{

			int shift= filterPos[i] + (*filterSize) - srcW;

			

			for(j=(*filterSize)-2; j>=0; j--)

			{

				int right= MIN(j + shift, (*filterSize)-1);

				filter[i*(*filterSize) +right] += filter[i*(*filterSize) +j];

				filter[i*(*filterSize) +j]=0;

			}

			filterPos[i]= srcW - (*filterSize);

		}

	}



	

	



	

	for(i=0; i<dstW; i++)

	{

		int j;

		double sum=0;

		double scale= one;

		for(j=0; j<*filterSize; j++)

		{

			sum+= filter[i*(*filterSize) + j];

		}

		scale/= sum;

		for(j=0; j<*filterSize; j++)

		{

			dstFilter[i*(*filterSize) + j]= (int)(filter[i*(*filterSize) + j]*scale);

		}

	}

}

#endif #endif static inline void RENAME(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc, 				      int srcW, int dstW, int filterAlign, int one) 	int i; 	double filter[8000]; #ifdef HAVE_MMX #endif 		int i; 		for(i=0; i<dstW*(*filterSize); i++) filter[i]=0; 		for(i=0; i<dstW; i++) 			filter[i*(*filterSize)]=1; 			filterPos[i]=i; 		int i; 		int xDstInSrc; 		if(sws_flags==SWS_BICUBIC) *filterSize= 4; 		else			   *filterSize= 2; 		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); 		xDstInSrc= xInc/2 - 0x8000; 		for(i=0; i<dstW; i++) 			int xx= (xDstInSrc>>16) - (*filterSize>>1) + 1; 			int j; 			filterPos[i]= xx; 			if(sws_flags == SWS_BICUBIC) 				double d= ABS(((xx+1)<<16) - xDstInSrc)/(double)(1<<16); 				double y1,y2,y3,y4; 				double A= -0.75; 				y1 = (        +     A*d -       2.0*A*d*d +       A*d*d*d); 				y2 = (+ 1.0             -     (A+3.0)*d*d + (A+2.0)*d*d*d); 				y3 = (        -     A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d); 				y4 = (                  +           A*d*d -       A*d*d*d); 				filter[i*(*filterSize) + 0]= y1; 				filter[i*(*filterSize) + 1]= y2; 				filter[i*(*filterSize) + 2]= y3; 				filter[i*(*filterSize) + 3]= y4; 				for(j=0; j<*filterSize; j++) 					double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16); 					double coeff= 1.0 - d; 					if(coeff<0) coeff=0; 					filter[i*(*filterSize) + j]= coeff; 					xx++; 			xDstInSrc+= xInc; 		int xDstInSrc; 		if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); 		else			   *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW); 		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); 		xDstInSrc= xInc/2 - 0x8000; 		for(i=0; i<dstW; i++) 			int xx= (int)((double)xDstInSrc/(double)(1<<16) - ((*filterSize)-1)*0.5 + 0.5); 			int j; 			filterPos[i]= xx; 			for(j=0; j<*filterSize; j++) 				double d= ABS((xx<<16) - xDstInSrc)/(double)xInc; 				double coeff; 				if(sws_flags == SWS_BICUBIC) 					double A= -0.75; 					if(d<1.0) 						coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d); 					else if(d<2.0) 						coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d); 						coeff=0.0; 					coeff= 1.0 - d; 					if(coeff<0) coeff=0; 				filter[i*(*filterSize) + j]= coeff; 				xx++; 			xDstInSrc+= xInc; 	for(i=0; i<dstW; i++) 		int j; 		if(filterPos[i] < 0) 			for(j=1; j<*filterSize; j++) 				int left= MAX(j + filterPos[i], 0); 				filter[i*(*filterSize) + left] += filter[i*(*filterSize) + j]; 				filter[i*(*filterSize) + j]=0; 			filterPos[i]= 0; 		if(filterPos[i] + (*filterSize) > srcW) 			int shift= filterPos[i] + (*filterSize) - srcW; 			for(j=(*filterSize)-2; j>=0; j--) 				int right= MIN(j + shift, (*filterSize)-1); 				filter[i*(*filterSize) +right] += filter[i*(*filterSize) +j]; 				filter[i*(*filterSize) +j]=0; 			filterPos[i]= srcW - (*filterSize); 	for(i=0; i<dstW; i++) 		int j; 		double sum=0; 		double scale= one; 		for(j=0; j<*filterSize; j++) 			sum+= filter[i*(*filterSize) + j]; 		scale/= sum; 		for(j=0; j<*filterSize; j++) 			dstFilter[i*(*filterSize) + j]= (int)(filter[i*(*filterSize) + j]*scale); #endif #endif #endif #endif #ifdef HAVE_MMX #endif #endif 		int i; #ifdef HAVE_MMX #endif #endif #ifdef HAVE_MMX #endif #ifdef HAVE_MMX #endif
static inline void FUNC_0(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc,

				      int srcW, int dstW, int filterAlign, int one)

{

	int VAR_2;

	double VAR_1[8000];

#ifdef HAVE_MMX

	asm volatile("emms\n\t"::: "memory"); 

#endif



	if(ABS(xInc - 0x10000) <10) 

	{

		int VAR_2;

		*filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); 

		for(VAR_2=0; VAR_2<dstW*(*filterSize); VAR_2++) VAR_1[VAR_2]=0;



		for(VAR_2=0; VAR_2<dstW; VAR_2++)

		{

			VAR_1[VAR_2*(*filterSize)]=1;

			filterPos[VAR_2]=VAR_2;

		}



	}

	else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR) 

	{

		int VAR_2;

		int VAR_3;

		if(sws_flags==SWS_BICUBIC) *filterSize= 4;

		else			   *filterSize= 2;



		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		VAR_3= xInc/2 - 0x8000;

		for(VAR_2=0; VAR_2<dstW; VAR_2++)

		{

			int xx= (VAR_3>>16) - (*filterSize>>1) + 1;

			int j;



			filterPos[VAR_2]= xx;

			if(sws_flags == SWS_BICUBIC)

			{

				double d= ABS(((xx+1)<<16) - VAR_3)/(double)(1<<16);

				double y1,y2,y3,y4;

				double A= -0.75;

					

				y1 = (        +     A*d -       2.0*A*d*d +       A*d*d*d);

				y2 = (+ 1.0             -     (A+3.0)*d*d + (A+2.0)*d*d*d);

				y3 = (        -     A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d);

				y4 = (                  +           A*d*d -       A*d*d*d);





				VAR_1[VAR_2*(*filterSize) + 0]= y1;

				VAR_1[VAR_2*(*filterSize) + 1]= y2;

				VAR_1[VAR_2*(*filterSize) + 2]= y3;

				VAR_1[VAR_2*(*filterSize) + 3]= y4;



			}

			else

			{

				for(j=0; j<*filterSize; j++)

				{

					double d= ABS((xx<<16) - VAR_3)/(double)(1<<16);

					double coeff= 1.0 - d;

					if(coeff<0) coeff=0;

	

					VAR_1[VAR_2*(*filterSize) + j]= coeff;

					xx++;

				}

			}

			VAR_3+= xInc;

		}

	}

	else 

	{

		int VAR_3;

		if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW);

		else			   *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW);



		*filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1));



		VAR_3= xInc/2 - 0x8000;

		for(VAR_2=0; VAR_2<dstW; VAR_2++)

		{

			int xx= (int)((double)VAR_3/(double)(1<<16) - ((*filterSize)-1)*0.5 + 0.5);

			int j;



			filterPos[VAR_2]= xx;

			for(j=0; j<*filterSize; j++)

			{

				double d= ABS((xx<<16) - VAR_3)/(double)xInc;

				double coeff;

				if(sws_flags == SWS_BICUBIC)

				{

					double A= -0.75;



					

					if(d<1.0)

						coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d);

					else if(d<2.0)

						coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d);

					else

						coeff=0.0;

				}

				else

				{

					coeff= 1.0 - d;

					if(coeff<0) coeff=0;

				}



				VAR_1[VAR_2*(*filterSize) + j]= coeff;

				xx++;

			}

			VAR_3+= xInc;

		}

	}



	

	for(VAR_2=0; VAR_2<dstW; VAR_2++)

	{

		int j;

		if(filterPos[VAR_2] < 0)

		{

			

			for(j=1; j<*filterSize; j++)

			{

				int left= MAX(j + filterPos[VAR_2], 0);

				VAR_1[VAR_2*(*filterSize) + left] += VAR_1[VAR_2*(*filterSize) + j];

				VAR_1[VAR_2*(*filterSize) + j]=0;

			}

			filterPos[VAR_2]= 0;

		}



		if(filterPos[VAR_2] + (*filterSize) > srcW)

		{

			int shift= filterPos[VAR_2] + (*filterSize) - srcW;

			

			for(j=(*filterSize)-2; j>=0; j--)

			{

				int right= MIN(j + shift, (*filterSize)-1);

				VAR_1[VAR_2*(*filterSize) +right] += VAR_1[VAR_2*(*filterSize) +j];

				VAR_1[VAR_2*(*filterSize) +j]=0;

			}

			filterPos[VAR_2]= srcW - (*filterSize);

		}

	}



	

	



	

	for(VAR_2=0; VAR_2<dstW; VAR_2++)

	{

		int j;

		double sum=0;

		double scale= one;

		for(j=0; j<*filterSize; j++)

		{

			sum+= VAR_1[VAR_2*(*filterSize) + j];

		}

		scale/= sum;

		for(j=0; j<*filterSize; j++)

		{

			dstFilter[VAR_2*(*filterSize) + j]= (int)(VAR_1[VAR_2*(*filterSize) + j]*scale);

		}

	}

}

static inline void FUNC_0(initFilter)(int16_t *dstFilter, int16_t *filterPos, int *filterSize, int xInc,
int srcW, int dstW, int filterAlign, int one)
{ int VAR_2; double VAR_1[8000]; #ifdef HAVE_MMX
asm volatile("emms\n\t"::: "memory"); #endif
if(ABS(xInc - 0x10000) <10)
{ int VAR_2; *filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); for(VAR_2=0; VAR_2<dstW*(*filterSize); VAR_2++) VAR_1[VAR_2]=0; for(VAR_2=0; VAR_2<dstW; VAR_2++) { VAR_1[VAR_2*(*filterSize)]=1; filterPos[VAR_2]=VAR_2; } } else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR)
{ int VAR_2; int VAR_3; if(sws_flags==SWS_BICUBIC) *filterSize= 4; else			   *filterSize= 2; *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); VAR_3= xInc/2 - 0x8000; for(VAR_2=0; VAR_2<dstW; VAR_2++) { int xx= (VAR_3>>16) - (*filterSize>>1) + 1; int j; filterPos[VAR_2]= xx; if(sws_flags == SWS_BICUBIC)
{ double d= ABS(((xx+1)<<16) - VAR_3)/(double)(1<<16); double y1,y2,y3,y4; double A= -0.75; y1 = (        +     A*d -       2.0*A*d*d +       A*d*d*d); y2 = (+ 1.0             -     (A+3.0)*d*d + (A+2.0)*d*d*d); y3 = (        -     A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d); y4 = (                  +           A*d*d -       A*d*d*d); VAR_1[VAR_2*(*filterSize) + 0]= y1; VAR_1[VAR_2*(*filterSize) + 1]= y2; VAR_1[VAR_2*(*filterSize) + 2]= y3; VAR_1[VAR_2*(*filterSize) + 3]= y4; } else
{ for(j=0; j<*filterSize; j++) { double d= ABS((xx<<16) - VAR_3)/(double)(1<<16); double coeff= 1.0 - d; if(coeff<0) coeff=0; VAR_1[VAR_2*(*filterSize) + j]= coeff; xx++; } } VAR_3+= xInc; } } else
{ int VAR_3; if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); else			   *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW); *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); VAR_3= xInc/2 - 0x8000; for(VAR_2=0; VAR_2<dstW; VAR_2++) { int xx= (int)((double)VAR_3/(double)(1<<16) - ((*filterSize)-1)*0.5 + 0.5); int j; filterPos[VAR_2]= xx; for(j=0; j<*filterSize; j++) { double d= ABS((xx<<16) - VAR_3)/(double)xInc; double coeff; if(sws_flags == SWS_BICUBIC)
{ double A= -0.75; if(d<1.0)
coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d); else if(d<2.0)
coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d); else
coeff=0.0; } else
{ coeff= 1.0 - d; if(coeff<0) coeff=0; } VAR_1[VAR_2*(*filterSize) + j]= coeff; xx++; } VAR_3+= xInc; } } for(VAR_2=0; VAR_2<dstW; VAR_2++) { int j; if(filterPos[VAR_2] < 0)
{ for(j=1; j<*filterSize; j++) { int left= MAX(j + filterPos[VAR_2], 0); VAR_1[VAR_2*(*filterSize) + left] += VAR_1[VAR_2*(*filterSize) + j]; VAR_1[VAR_2*(*filterSize) + j]=0; } filterPos[VAR_2]= 0; } if(filterPos[VAR_2] + (*filterSize) > srcW)
{ int shift= filterPos[VAR_2] + (*filterSize) - srcW; for(j=(*filterSize)-2; j>=0; j--) { int right= MIN(j + shift, (*filterSize)-1); VAR_1[VAR_2*(*filterSize) +right] += VAR_1[VAR_2*(*filterSize) +j]; VAR_1[VAR_2*(*filterSize) +j]=0; } filterPos[VAR_2]= srcW - (*filterSize); } } for(VAR_2=0; VAR_2<dstW; VAR_2++) { int j; double sum=0; double scale= one; for(j=0; j<*filterSize; j++) { sum+= VAR_1[VAR_2*(*filterSize) + j]; } scale/= sum; for(j=0; j<*filterSize; j++) { dstFilter[VAR_2*(*filterSize) + j]= (int)(VAR_1[VAR_2*(*filterSize) + j]*scale); } } }