XilinxProcessorIPLib/drivers/v_vscaler/src/xv_vscaler_l2.c
static void XV_VScalerSelectCoeff(XV_Vscaler_l2 *InstancePtr,
		                          u32 HeightIn,
		                          u32 HeightOut)
{
  const short *coeff;
  u16 numTaps, numPhases;
  u16 ScalingRatio;
  u16 IsScaleDown;

  /*
   * validates input arguments
   */
  Xil_AssertVoid(InstancePtr != NULL);

  numPhases = (1<<InstancePtr->Vsc.Config.PhaseShift);

  IsScaleDown = (HeightOut < HeightIn);
  /* Scale Down Mode will use dynamic filter selection logic
   * Scale Up Mode (including 1:1) will always use 6 tap filter
   */
  if(IsScaleDown)
  {
    ScalingRatio = ((HeightIn * 10)/HeightOut);

    switch(InstancePtr->Vsc.Config.NumTaps)
    {
	case XV_VSCALER_TAPS_6:
		if (ScalingRatio > 35) {// > 3.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else if (ScalingRatio > 25) {//2.6 < Ratio <= 3.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else if (ScalingRatio > 15) {//1.6 < Ratio <= 2.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else {// <= 1.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;

	case XV_VSCALER_TAPS_8:
		if (ScalingRatio > 35) {// > 3.5
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else if (ScalingRatio > 25) {//2.6 < Ratio <= 3.5
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else if (ScalingRatio > 15) {//1.6 < Ratio <= 2.5
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {// <= 1.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;

	case XV_VSCALER_TAPS_10:
		if (ScalingRatio > 35) {// > 3.5
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 25) {//2.6 < Ratio <= 3.5
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 15) {//1.6 < Ratio <= 2.5
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {// <= 1.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;

	case XV_VSCALER_TAPS_12:
		if (ScalingRatio > 35) {// > 3.5
			coeff = &XV_vscaler_fixedcoeff_taps12_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_12;
		} else if (ScalingRatio > 25) {//2.6 < Ratio <= 3.5
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 15) {//1.6 < Ratio <= 2.5
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {// <= 1.5
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;

	default:
		return;
	}
  }
  else //Scale Up
  {
	coeff = &XV_vscaler_Lanczos2_taps6[0][0];
	numTaps = XV_VSCALER_TAPS_6;
  }

  XV_VScalerLoadExtCoeff(InstancePtr,
		                 numPhases,
		                 numTaps,
		                 coeff);

  /* Disable use of external coefficients */
  InstancePtr->UseExtCoeff = FALSE;
}
/*****************************************************************************/
/**
* This function loads default filter coefficients in the scaler coefficient
* storage based on the selected TAP configuration
*
* @param  InstancePtr is a pointer to the core instance to be worked on.
* @param  WidthIn is the input stream height
* @param  Widthout is the output stream height

* @return None
*
******************************************************************************/
This function loads default filter coefficients in the scaler coefficient
storage based on the selected TAP configuration
This function loads default filter coefficients in the scaler coefficient storage based on the selected TAP configuration
static void XV_VScalerSelectCoeff(XV_Vscaler_l2 *InstancePtr,
		                          u32 HeightIn,
		                          u32 HeightOut)
{
  const short *coeff;
  u16 numTaps, numPhases;
  u16 ScalingRatio;
  u16 IsScaleDown;
  Xil_AssertVoid(InstancePtr != NULL);
  numPhases = (1<<InstancePtr->Vsc.Config.PhaseShift);
  IsScaleDown = (HeightOut < HeightIn);
  if(IsScaleDown)
  {
    ScalingRatio = ((HeightIn * 10)/HeightOut);
    switch(InstancePtr->Vsc.Config.NumTaps)
    {
	case XV_VSCALER_TAPS_6:
		if (ScalingRatio > 35) {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else if (ScalingRatio > 25) {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else if (ScalingRatio > 15) {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		} else {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;
	case XV_VSCALER_TAPS_8:
		if (ScalingRatio > 35) {
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else if (ScalingRatio > 25) {
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else if (ScalingRatio > 15) {
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;
	case XV_VSCALER_TAPS_10:
		if (ScalingRatio > 35) {
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 25) {
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 15) {
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;
	case XV_VSCALER_TAPS_12:
		if (ScalingRatio > 35) {
			coeff = &XV_vscaler_fixedcoeff_taps12_ScalingRatio4[0][0];
			numTaps = XV_VSCALER_TAPS_12;
		} else if (ScalingRatio > 25) {
			coeff = &XV_vscaler_fixedcoeff_taps10_ScalingRatio3[0][0];
			numTaps = XV_VSCALER_TAPS_10;
		} else if (ScalingRatio > 15) {
			coeff = &XV_vscaler_fixedcoeff_taps8_ScalingRatio2[0][0];
			numTaps = XV_VSCALER_TAPS_8;
		} else {
			coeff = &XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2[0][0];
			numTaps = XV_VSCALER_TAPS_6;
		}
	break;
	default:
		return;
	}
  }
  else 
  {
	coeff = &XV_vscaler_Lanczos2_taps6[0][0];
	numTaps = XV_VSCALER_TAPS_6;
  }
  XV_VScalerLoadExtCoeff(InstancePtr,
		                 numPhases,
		                 numTaps,
		                 coeff);
  InstancePtr->UseExtCoeff = FALSE;
}
static void XV_VScalerSelectCoeff ( XV_Vscaler_l2 * InstancePtr , u32 HeightIn , u32 HeightOut ) { const short * coeff ; u16 numTaps , numPhases ; u16 ScalingRatio ; u16 IsScaleDown ; Xil_AssertVoid ( InstancePtr != NULL ) ; numPhases = ( 1 << InstancePtr -> Vsc . Config . PhaseShift ) ; IsScaleDown = ( HeightOut < HeightIn ) ; if ( IsScaleDown ) { ScalingRatio = ( ( HeightIn * 10 ) / HeightOut ) ; switch ( InstancePtr -> Vsc . Config . NumTaps ) { case XV_VSCALER_TAPS_6 : if ( ScalingRatio > 35 ) { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio4 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } else if ( ScalingRatio > 25 ) { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio3 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } else if ( ScalingRatio > 15 ) { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } else { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } break ; case XV_VSCALER_TAPS_8 : if ( ScalingRatio > 35 ) { coeff = & XV_vscaler_fixedcoeff_taps8_ScalingRatio4 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_8 ; } else if ( ScalingRatio > 25 ) { coeff = & XV_vscaler_fixedcoeff_taps8_ScalingRatio3 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_8 ; } else if ( ScalingRatio > 15 ) { coeff = & XV_vscaler_fixedcoeff_taps8_ScalingRatio2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_8 ; } else { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } break ; case XV_VSCALER_TAPS_10 : if ( ScalingRatio > 35 ) { coeff = & XV_vscaler_fixedcoeff_taps10_ScalingRatio4 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_10 ; } else if ( ScalingRatio > 25 ) { coeff = & XV_vscaler_fixedcoeff_taps10_ScalingRatio3 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_10 ; } else if ( ScalingRatio > 15 ) { coeff = & XV_vscaler_fixedcoeff_taps8_ScalingRatio2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_8 ; } else { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } break ; case XV_VSCALER_TAPS_12 : if ( ScalingRatio > 35 ) { coeff = & XV_vscaler_fixedcoeff_taps12_ScalingRatio4 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_12 ; } else if ( ScalingRatio > 25 ) { coeff = & XV_vscaler_fixedcoeff_taps10_ScalingRatio3 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_10 ; } else if ( ScalingRatio > 15 ) { coeff = & XV_vscaler_fixedcoeff_taps8_ScalingRatio2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_8 ; } else { coeff = & XV_vscaler_fixedcoeff_taps6_ScalingRatio1p2 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } break ; default : return ; } } else { coeff = & XV_vscaler_Lanczos2_taps6 [ 0 ] [ 0 ] ; numTaps = XV_VSCALER_TAPS_6 ; } XV_VScalerLoadExtCoeff ( InstancePtr , numPhases , numTaps , coeff ) ; InstancePtr -> UseExtCoeff = FALSE ; }
This function loads default filter coefficients in the scaler coefficient
storage based on the selected TAP configuration
This function loads default filter coefficients in the scaler coefficient storage based on the selected TAP configuration
/*
   * validates input arguments
   */ /* Scale Down Mode will use dynamic filter selection logic
   * Scale Up Mode (including 1:1) will always use 6 tap filter
   */ // > 3.5 //2.6 < Ratio <= 3.5 //1.6 < Ratio <= 2.5 // <= 1.5 // > 3.5 //2.6 < Ratio <= 3.5 //1.6 < Ratio <= 2.5 // <= 1.5 // > 3.5 //2.6 < Ratio <= 3.5 //1.6 < Ratio <= 2.5 // <= 1.5 // > 3.5 //2.6 < Ratio <= 3.5 //1.6 < Ratio <= 2.5 // <= 1.5 //Scale Up /* Disable use of external coefficients */