if(x - 8 >= 0 && x<width)
if(x - 8 >= 0)
static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,	QP_STORE_T QPs[], int QPStride, int isColor, int mode){	int x,y;	/* we need 64bit here otherwise well going to have a problem	   after watching a black picture for 5 hours*/	static uint64_t *yHistogram= NULL;	int black=0, white=255; // blackest black and whitest white in the picture	/* Temporary buffers for handling the last row(s) */	static uint8_t *tempDst= NULL;	static uint8_t *tempSrc= NULL;#ifdef TIMING	long long T0, T1, memcpyTime=0, vertTime=0, horizTime=0, sumTime, diffTime=0;	sumTime= rdtsc();#endif	if(tempDst==NULL)	{		tempDst= (uint8_t*)memalign(8, 1024*24);		tempSrc= (uint8_t*)memalign(8, 1024*24);	}	if(!yHistogram)	{		int i;		yHistogram= (uint64_t*)malloc(8*256);		for(i=0; i<256; i++) yHistogram[i]= width*height/64*15/256;	}	if(!isColor)	{		uint64_t sum= 0;		int i;		static int framenum= -1;		uint64_t maxClipped;		uint64_t clipped;		double scale;		framenum++;		if(framenum == 1) yHistogram[0]= width*height/64*15/256;		for(i=0; i<256; i++)		{			sum+= yHistogram[i];//			printf("%d ", yHistogram[i]);		}//		printf("\n\n");		/* we allways get a completly black picture first */		maxClipped= (uint64_t)(sum * maxClippedThreshold);		clipped= sum;		for(black=255; black>0; black--)		{			if(clipped < maxClipped) break;			clipped-= yHistogram[black];		}		clipped= sum;		for(white=0; white<256; white++)		{			if(clipped < maxClipped) break;			clipped-= yHistogram[white];		}		// we cant handle negative correctures		packedYOffset= MAX(black - minAllowedY, 0);		packedYOffset|= packedYOffset<<32;		packedYOffset|= packedYOffset<<16;		packedYOffset|= packedYOffset<<8;		scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black);		packedYScale= (uint16_t)(scale*512.0 + 0.5);		packedYScale|= packedYScale<<32;		packedYScale|= packedYScale<<16;	}	else	{		packedYScale= 0x0100010001000100LL;		packedYOffset= 0;	}	/* copy first row of 8x8 blocks */	for(x=0; x<width; x+=BLOCK_SIZE)		blockCopy(dst + x, dstStride, src + x, srcStride, 8, mode & LEVEL_FIX);	for(y=0; y<height; y+=BLOCK_SIZE)	{		//1% speedup if these are here instead of the inner loop		uint8_t *srcBlock= &(src[y*srcStride]);		uint8_t *dstBlock= &(dst[y*dstStride]);		/* can we mess with a 8x16 block from srcBlock/dstBlock downwards, if not		   than use a temporary buffer */		if(y+15 >= height)		{			/* copy from line 5 to 12 of src, these will e copied with			   blockcopy to dst later */			memcpy(tempSrc + srcStride*5, srcBlock + srcStride*5,				srcStride*MAX(height-y-5, 0) );			/* duplicate last line to fill the void upto line 12 */			if(y+12 >= height)			{				int i;				for(i=height-y; i<=12; i++)					memcpy(tempSrc + srcStride*i,						src + srcStride*(height-1), srcStride);			}			/* copy up to 5 lines of dst */			memcpy(tempDst, dstBlock, dstStride*MIN(height-y, 5) );			dstBlock= tempDst;			srcBlock= tempSrc;		}		// finish 1 block before the next otherwise well might have a problem		// with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing		for(x=0; x<width; x+=BLOCK_SIZE)		{			const int stride= dstStride;			int QP= isColor ?				QPs[(y>>3)*QPStride + (x>>3)]:				QPs[(y>>4)*QPStride + (x>>4)];			if(!isColor && (mode & LEVEL_FIX)) QP= (QP* (packedYScale &0xFFFF))>>8;#ifdef HAVE_MMX			asm volatile(				"movd %0, %%mm7					\n\t"				"packuswb %%mm7, %%mm7				\n\t" // 0, 0, 0, QP, 0, 0, 0, QP				"packuswb %%mm7, %%mm7				\n\t" // 0,QP, 0, QP, 0,QP, 0, QP				"packuswb %%mm7, %%mm7				\n\t" // QP,..., QP				"movq %%mm7, pQPb				\n\t"				: : "r" (QP)			);#endif#ifdef MORE_TIMING			T0= rdtsc();#endif#ifdef HAVE_MMX2			prefetchnta(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);			prefetchnta(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);			prefetcht0(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);			prefetcht0(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);#elif defined(HAVE_3DNOW)//FIXME check if this is faster on an 3dnow chip or if its faster without the prefetch or .../*			prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);			prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);			prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);			prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);*/#endif			if(!isColor) yHistogram[ srcBlock[srcStride*5] ]++;			blockCopy(dstBlock + dstStride*5, dstStride,				srcBlock + srcStride*5, srcStride, 8, mode & LEVEL_FIX);			if(mode & LINEAR_IPOL_DEINT_FILTER)				deInterlaceInterpolateLinear(dstBlock, dstStride);			else if(mode & LINEAR_BLEND_DEINT_FILTER)				deInterlaceBlendLinear(dstBlock, dstStride);			else if(mode & MEDIAN_DEINT_FILTER)				deInterlaceMedian(dstBlock, dstStride);			else if(mode & CUBIC_IPOL_DEINT_FILTER)				deInterlaceInterpolateCubic(dstBlock, dstStride);/*			else if(mode & CUBIC_BLEND_DEINT_FILTER)				deInterlaceBlendCubic(dstBlock, dstStride);*/			/* only deblock if we have 2 blocks */			if(y + 8 < height)			{#ifdef MORE_TIMING				T1= rdtsc();				memcpyTime+= T1-T0;				T0=T1;#endif				if(mode & V_DEBLOCK)				{					if(mode & V_RK1_FILTER)						vertRK1Filter(dstBlock, stride, QP);					else if(mode & V_X1_FILTER)						vertX1Filter(dstBlock, stride, QP);					else					{						if( isVertDC(dstBlock, stride))						{							if(isVertMinMaxOk(dstBlock, stride, QP))								doVertLowPass(dstBlock, stride, QP);						}						else							doVertDefFilter(dstBlock, stride, QP);					}				}#ifdef MORE_TIMING				T1= rdtsc();				vertTime+= T1-T0;				T0=T1;#endif			}			/* check if we have a previous block to deblock it with dstBlock */			if(x - 8 >= 0 && x<width)			{#ifdef MORE_TIMING				T0= rdtsc();#endif				if(mode & H_DEBLOCK)				{					if(mode & H_X1_FILTER)						horizX1Filter(dstBlock-4, stride, QP);					else					{						if( isHorizDCAndCopy2Temp(dstBlock-4, stride))						{							if(isHorizMinMaxOk(tempBlock, TEMP_STRIDE, QP))								doHorizLowPassAndCopyBack(dstBlock-4, stride, QP);						}						else							doHorizDefFilterAndCopyBack(dstBlock-4, stride, QP);					}				}#ifdef MORE_TIMING				T1= rdtsc();				horizTime+= T1-T0;				T0=T1;#endif				dering(dstBlock - 9 - stride, stride, QP);			}			else if(y!=0)				dering(dstBlock - stride*9 + width-9, stride, QP);			//FIXME dering filter will not be applied to last block (bottom right)			dstBlock+=8;			srcBlock+=8;		}		/* did we use a tmp buffer */		if(y+15 > height)		{			uint8_t *dstBlock= &(dst[y*dstStride]);			memcpy(dstBlock, tempDst, dstStride*(height-y) );		}	}#ifdef HAVE_3DNOW	asm volatile("femms");#elif defined (HAVE_MMX)	asm volatile("emms");#endif#ifdef TIMING	// FIXME diff is mostly the time spent for rdtsc (should subtract that but ...)	sumTime= rdtsc() - sumTime;	if(!isColor)		printf("cpy:%4dk, vert:%4dk, horiz:%4dk, sum:%4dk, diff:%4dk, color: %d/%d    \r",			(int)(memcpyTime/1000), (int)(vertTime/1000), (int)(horizTime/1000),			(int)(sumTime/1000), (int)((sumTime-memcpyTime-vertTime-horizTime)/1000)			, black, white);#endif}