XilinxProcessorIPLib/drivers/v_hscaler/src/xv_hscaler_l2.c
static void CalculatePhases(XV_Hscaler_l2 *HscPtr,
                            u32 WidthIn,
                            u32 WidthOut,
                            u32 PixelRate)
{
    int loopWidth;
    int x,s;
    int offset = 0;
    int xWritePos = 0;
    u64 OutputWriteEn;
    int GetNewPix;
    u64 PhaseH;
    u64 arrayIdx;
    int xReadPos = 0;
    int nrRds = 0;
    int nrRdsClck = 0;
    int MaxPhases = (1<<HscPtr->Hsc.Config.PhaseShift);
    loopWidth = ((WidthIn > WidthOut) ? WidthIn + (HscPtr->Hsc.Config.PixPerClk-1)
                                      : WidthOut  +(HscPtr->Hsc.Config.PixPerClk-1))/HscPtr->Hsc.Config.PixPerClk;


    arrayIdx = 0;
    for (x=0; x<loopWidth; x++)
    {
        HscPtr->phasesH[x] = 0;
	HscPtr->phasesH_H[x] = 0;
	nrRdsClck = 0;
        for (s=0; s<HscPtr->Hsc.Config.PixPerClk; s++)
        {
            PhaseH = (offset>>(STEP_PRECISION_SHIFT-HscPtr->Hsc.Config.PhaseShift)) & (MaxPhases-1);//(HSC_PHASES-1);
            GetNewPix = 0;
            OutputWriteEn = 0;
            if ((offset >> STEP_PRECISION_SHIFT) != 0)
            {
                // read a new input sample
                GetNewPix = 1;
                offset = offset - (1<<STEP_PRECISION_SHIFT);
                OutputWriteEn = 0;
                arrayIdx++;
                xReadPos++;
            }

            if (((offset >> STEP_PRECISION_SHIFT) == 0) && (xWritePos< (int)WidthOut))
            {
                // produce a new output sample
                offset += PixelRate;
                OutputWriteEn = 1;
                xWritePos++;
            }

	    if (HscPtr->Hsc.Config.PixPerClk == XVIDC_PPC_8)
	    {
		    if (s < 4 ) {
			    HscPtr->phasesH[x] |= (PhaseH << (s*11));
			    HscPtr->phasesH[x] |= (arrayIdx << (6 + (s*11)));
			    HscPtr->phasesH[x] |= (OutputWriteEn << (10 + (s*11)));
		    } else {
			    HscPtr->phasesH_H[x] |= (PhaseH << ((s-4)*11));
			    HscPtr->phasesH_H[x] |= (arrayIdx << (6 + ((s-4)*11)));
			    HscPtr->phasesH_H[x] |= (OutputWriteEn << (10 + ((s-4)*11)));
		    }
	    } else if (HscPtr->Hsc.Config.PixPerClk == XVIDC_PPC_4) {
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (PhaseH << (s*10));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (arrayIdx << (6 + (s*10)));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (OutputWriteEn << (9 + (s*10)));
            }
            else
            {
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (PhaseH << (s*9));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (arrayIdx << (6 + (s*9)));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (OutputWriteEn << (8 + (s*9)));
            }

            if (GetNewPix) nrRdsClck++;
        }
        if (arrayIdx>=HscPtr->Hsc.Config.PixPerClk)
            arrayIdx &= (HscPtr->Hsc.Config.PixPerClk-1);

        nrRds += nrRdsClck;
        if (nrRds >= HscPtr->Hsc.Config.PixPerClk)
            nrRds -= HscPtr->Hsc.Config.PixPerClk;
    }
}
/*****************************************************************************/
/**
* This function calculates the phases for 1 line. Same phase info is used for
* full frame
*
* @param  HscPtr is a pointer to the core instance to be worked on.
* @param  WidthIn is the input frame width
* @param  WidthOut is the scaled frame width
* @param  PixelRate is the number of pixels per clock being processed
*
* @return None
*
******************************************************************************/
This function calculates the phases for 1 line. Same phase info is used for
full frame
This function calculates the phases for 1 line . Same phase info is used for full frame
static void CalculatePhases(XV_Hscaler_l2 *HscPtr,
                            u32 WidthIn,
                            u32 WidthOut,
                            u32 PixelRate)
{
    int loopWidth;
    int x,s;
    int offset = 0;
    int xWritePos = 0;
    u64 OutputWriteEn;
    int GetNewPix;
    u64 PhaseH;
    u64 arrayIdx;
    int xReadPos = 0;
    int nrRds = 0;
    int nrRdsClck = 0;
    int MaxPhases = (1<<HscPtr->Hsc.Config.PhaseShift);
    loopWidth = ((WidthIn > WidthOut) ? WidthIn + (HscPtr->Hsc.Config.PixPerClk-1)
                                      : WidthOut  +(HscPtr->Hsc.Config.PixPerClk-1))/HscPtr->Hsc.Config.PixPerClk;
    arrayIdx = 0;
    for (x=0; x<loopWidth; x++)
    {
        HscPtr->phasesH[x] = 0;
	HscPtr->phasesH_H[x] = 0;
	nrRdsClck = 0;
        for (s=0; s<HscPtr->Hsc.Config.PixPerClk; s++)
        {
            PhaseH = (offset>>(STEP_PRECISION_SHIFT-HscPtr->Hsc.Config.PhaseShift)) & (MaxPhases-1);
            GetNewPix = 0;
            OutputWriteEn = 0;
            if ((offset >> STEP_PRECISION_SHIFT) != 0)
            {
                GetNewPix = 1;
                offset = offset - (1<<STEP_PRECISION_SHIFT);
                OutputWriteEn = 0;
                arrayIdx++;
                xReadPos++;
            }
            if (((offset >> STEP_PRECISION_SHIFT) == 0) && (xWritePos< (int)WidthOut))
            {
                offset += PixelRate;
                OutputWriteEn = 1;
                xWritePos++;
            }
	    if (HscPtr->Hsc.Config.PixPerClk == XVIDC_PPC_8)
	    {
		    if (s < 4 ) {
			    HscPtr->phasesH[x] |= (PhaseH << (s*11));
			    HscPtr->phasesH[x] |= (arrayIdx << (6 + (s*11)));
			    HscPtr->phasesH[x] |= (OutputWriteEn << (10 + (s*11)));
		    } else {
			    HscPtr->phasesH_H[x] |= (PhaseH << ((s-4)*11));
			    HscPtr->phasesH_H[x] |= (arrayIdx << (6 + ((s-4)*11)));
			    HscPtr->phasesH_H[x] |= (OutputWriteEn << (10 + ((s-4)*11)));
		    }
	    } else if (HscPtr->Hsc.Config.PixPerClk == XVIDC_PPC_4) {
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (PhaseH << (s*10));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (arrayIdx << (6 + (s*10)));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (OutputWriteEn << (9 + (s*10)));
            }
            else
            {
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (PhaseH << (s*9));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (arrayIdx << (6 + (s*9)));
              HscPtr->phasesH[x] = HscPtr->phasesH[x] | (OutputWriteEn << (8 + (s*9)));
            }
            if (GetNewPix) nrRdsClck++;
        }
        if (arrayIdx>=HscPtr->Hsc.Config.PixPerClk)
            arrayIdx &= (HscPtr->Hsc.Config.PixPerClk-1);
        nrRds += nrRdsClck;
        if (nrRds >= HscPtr->Hsc.Config.PixPerClk)
            nrRds -= HscPtr->Hsc.Config.PixPerClk;
    }
}
static void CalculatePhases ( XV_Hscaler_l2 * HscPtr , u32 WidthIn , u32 WidthOut , u32 PixelRate ) { int loopWidth ; int x , s ; int offset = 0 ; int xWritePos = 0 ; u64 OutputWriteEn ; int GetNewPix ; u64 PhaseH ; u64 arrayIdx ; int xReadPos = 0 ; int nrRds = 0 ; int nrRdsClck = 0 ; int MaxPhases = ( 1 << HscPtr -> Hsc . Config . PhaseShift ) ; loopWidth = ( ( WidthIn > WidthOut ) ? WidthIn + ( HscPtr -> Hsc . Config . PixPerClk - 1 ) : WidthOut + ( HscPtr -> Hsc . Config . PixPerClk - 1 ) ) / HscPtr -> Hsc . Config . PixPerClk ; arrayIdx = 0 ; for ( x = 0 ; x < loopWidth ; x ++ ) { HscPtr -> phasesH [ x ] = 0 ; HscPtr -> phasesH_H [ x ] = 0 ; nrRdsClck = 0 ; for ( s = 0 ; s < HscPtr -> Hsc . Config . PixPerClk ; s ++ ) { PhaseH = ( offset >> ( STEP_PRECISION_SHIFT - HscPtr -> Hsc . Config . PhaseShift ) ) & ( MaxPhases - 1 ) ; GetNewPix = 0 ; OutputWriteEn = 0 ; if ( ( offset >> STEP_PRECISION_SHIFT ) != 0 ) { GetNewPix = 1 ; offset = offset - ( 1 << STEP_PRECISION_SHIFT ) ; OutputWriteEn = 0 ; arrayIdx ++ ; xReadPos ++ ; } if ( ( ( offset >> STEP_PRECISION_SHIFT ) == 0 ) && ( xWritePos < ( int ) WidthOut ) ) { offset += PixelRate ; OutputWriteEn = 1 ; xWritePos ++ ; } if ( HscPtr -> Hsc . Config . PixPerClk == XVIDC_PPC_8 ) { if ( s < 4 ) { HscPtr -> phasesH [ x ] |= ( PhaseH << ( s * 11 ) ) ; HscPtr -> phasesH [ x ] |= ( arrayIdx << ( 6 + ( s * 11 ) ) ) ; HscPtr -> phasesH [ x ] |= ( OutputWriteEn << ( 10 + ( s * 11 ) ) ) ; } else { HscPtr -> phasesH_H [ x ] |= ( PhaseH << ( ( s - 4 ) * 11 ) ) ; HscPtr -> phasesH_H [ x ] |= ( arrayIdx << ( 6 + ( ( s - 4 ) * 11 ) ) ) ; HscPtr -> phasesH_H [ x ] |= ( OutputWriteEn << ( 10 + ( ( s - 4 ) * 11 ) ) ) ; } } else if ( HscPtr -> Hsc . Config . PixPerClk == XVIDC_PPC_4 ) { HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( PhaseH << ( s * 10 ) ) ; HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( arrayIdx << ( 6 + ( s * 10 ) ) ) ; HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( OutputWriteEn << ( 9 + ( s * 10 ) ) ) ; } else { HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( PhaseH << ( s * 9 ) ) ; HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( arrayIdx << ( 6 + ( s * 9 ) ) ) ; HscPtr -> phasesH [ x ] = HscPtr -> phasesH [ x ] | ( OutputWriteEn << ( 8 + ( s * 9 ) ) ) ; } if ( GetNewPix ) nrRdsClck ++ ; } if ( arrayIdx >= HscPtr -> Hsc . Config . PixPerClk ) arrayIdx &= ( HscPtr -> Hsc . Config . PixPerClk - 1 ) ; nrRds += nrRdsClck ; if ( nrRds >= HscPtr -> Hsc . Config . PixPerClk ) nrRds -= HscPtr -> Hsc . Config . PixPerClk ; } }
This function calculates the phases for 1 line.
This function calculates the phases for 1 line .
//(HSC_PHASES-1); // read a new input sample // produce a new output sample