XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c
u32 XRgb2YCrCb_Coefficient_Translation(XRgb2YCrCb *InstancePtr,
				struct XRgb2YCrCb_Coef_Inputs *CoefIn,
				struct XRgb2YCrCb_Coef_Outputs *CoefOut,
				u32 DataWidth)
{
	u32 RetVal = 0;

	/* Verify arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(CoefIn != NULL);
	Xil_AssertNonvoid(CoefOut != NULL);

	Xil_AssertNonvoid( (DataWidth == (u32)(XRGB_DATA_WIDTH_16))  ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_10)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_12)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_8)));

	if((CoefIn->ACoef + CoefIn->BCoef) > (1.0)) {
		RetVal = (RetVal) | (0x1);
	}
	if((((int)CoefIn->YOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->YOffset) > ((int)((1 << DataWidth) -1 )))) {
		RetVal = (RetVal) | (0x2);
	}
	if((((int)CoefIn->CbOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->CbOffset) > ((int)((1 << DataWidth) - 1)))) {
		RetVal = (RetVal) | (0x4);
	}
	if((((int)CoefIn->CrOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->CrOffset) > ((int)((1 << DataWidth) - 1)))) {
		RetVal = (RetVal) | (0x8);
	}
	if(((int)CoefIn->YMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x10);
	}
	if(((int)CoefIn->YMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x20);
	}
	if(((int)CoefIn->CbMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x40);
	}
	if(((int)CoefIn->CbMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x80);
	}
	if(((int)CoefIn->CrMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x100);
	}
	if(((int)CoefIn->CrMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x200);
	}

	CoefOut->ACoef = CoefIn->ACoef * (1 << 16);
	CoefOut->BCoef = CoefIn->BCoef * (1 << 16);
	CoefOut->CCoef = CoefIn->CCoef * (1 << 16);
	CoefOut->DCoef = CoefIn->DCoef * (1 << 16);
	CoefOut->YOffset  = CoefIn->YOffset;
	CoefOut->CbOffset = CoefIn->CbOffset;
	CoefOut->CrOffset = CoefIn->CrOffset;
	CoefOut->YMax  = CoefIn->YMax;
	CoefOut->YMin  = CoefIn->YMin;
	CoefOut->CbMax = CoefIn->CbMax;
	CoefOut->CbMin = CoefIn->CbMin;
	CoefOut->CrMax = CoefIn->CrMax;
	CoefOut->CrMin = CoefIn->CrMin;

	return RetVal;
}
/*****************************************************************************/
/**
*
* This function translates the XRgb2YCrCb_Coef_Inputs structure into the
* XRgb2YCrCb_Coef_Outputs structure that can be used to program the core's
* registers. The XRgb2YCrCb_Coef_Inputs structure uses the same values as the
* core's GUIs. The XRgb2YCrCb_Coef_Outputs structure uses the values that can
* be programmed into the core's registers.
*
* @param	InstancePtr is a pointer to the XRgb2YCrCb instance.
* @param	CoefIn specifies a pointer to a XRgb2YCrCb_Coef_Inputs
*		structure to be translated.
* @param	CoefOut specifies a pointer to a XRgb2YCrCb_Coef_Outputs
*		structure with translated values.
* @param	DataWidth specifies a valid range of [8,10,12,16] that needs
*		to be set.
*
* @return	RetVal, returns the 32-bit value with following bit information:
*		- bit(0)= ACoef + BCoef > 1.0.
*		- bit(1)= Y Offset outside data width range as
*			[-2^Data_Width, (2^Data_Width)-1].
*		- bit(2)= Cb Offset outside data width range as
*			[-2^Data_Width, (2^Data_Width)-1].
*		- bit(3)= Cr Offset outside data width range as
*			[-2^Data_Width, (2^Data_Width)-1].
*		- bit(4)= Y Max outside data width range as
*			[0, (2^Data_Width)-1].
*		- bit(5)= Y Min outside data width range as
*			[0, (2^Data_Width)-1].
*		- bit(6)= Cb Max outside data width range as
*			[0, (2^Data_Width)-1].
*		- bit(7)= Cb Min outside data width range as
*			[0, (2^Data_Width)-1].
*		- bit(8)= Cr Max outside data width range as
*			[0, (2^Data_Width)-1].
*		- bit(9)= Cr Min outside data width range as
*			[0, (2^Data_Width)-1].
*
* @note		None.
*
******************************************************************************/
This function translates the XRgb2YCrCb_Coef_Inputs structure into the
XRgb2YCrCb_Coef_Outputs structure that can be used to program the core's
registers. The XRgb2YCrCb_Coef_Inputs structure uses the same values as the
core's GUIs. The XRgb2YCrCb_Coef_Outputs structure uses the values that can
be programmed into the core's registers.
This function translates the XRgb2YCrCb_Coef_Inputs structure into the XRgb2YCrCb_Coef_Outputs structure that can be used to program the core ' s registers . The XRgb2YCrCb_Coef_Inputs structure uses the same values as the core ' s GUIs . The XRgb2YCrCb_Coef_Outputs structure uses the values that can be programmed into the core ' s registers .
u32 XRgb2YCrCb_Coefficient_Translation(XRgb2YCrCb *InstancePtr,
				struct XRgb2YCrCb_Coef_Inputs *CoefIn,
				struct XRgb2YCrCb_Coef_Outputs *CoefOut,
				u32 DataWidth)
{
	u32 RetVal = 0;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(CoefIn != NULL);
	Xil_AssertNonvoid(CoefOut != NULL);
	Xil_AssertNonvoid( (DataWidth == (u32)(XRGB_DATA_WIDTH_16))  ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_10)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_12)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_8)));
	if((CoefIn->ACoef + CoefIn->BCoef) > (1.0)) {
		RetVal = (RetVal) | (0x1);
	}
	if((((int)CoefIn->YOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->YOffset) > ((int)((1 << DataWidth) -1 )))) {
		RetVal = (RetVal) | (0x2);
	}
	if((((int)CoefIn->CbOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->CbOffset) > ((int)((1 << DataWidth) - 1)))) {
		RetVal = (RetVal) | (0x4);
	}
	if((((int)CoefIn->CrOffset) < ((int)-(1 << DataWidth))) ||
		(((int)CoefIn->CrOffset) > ((int)((1 << DataWidth) - 1)))) {
		RetVal = (RetVal) | (0x8);
	}
	if(((int)CoefIn->YMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x10);
	}
	if(((int)CoefIn->YMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x20);
	}
	if(((int)CoefIn->CbMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x40);
	}
	if(((int)CoefIn->CbMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x80);
	}
	if(((int)CoefIn->CrMax) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x100);
	}
	if(((int)CoefIn->CrMin) > ((int)((1 << DataWidth) - 1))) {
		RetVal = (RetVal) | (0x200);
	}
	CoefOut->ACoef = CoefIn->ACoef * (1 << 16);
	CoefOut->BCoef = CoefIn->BCoef * (1 << 16);
	CoefOut->CCoef = CoefIn->CCoef * (1 << 16);
	CoefOut->DCoef = CoefIn->DCoef * (1 << 16);
	CoefOut->YOffset  = CoefIn->YOffset;
	CoefOut->CbOffset = CoefIn->CbOffset;
	CoefOut->CrOffset = CoefIn->CrOffset;
	CoefOut->YMax  = CoefIn->YMax;
	CoefOut->YMin  = CoefIn->YMin;
	CoefOut->CbMax = CoefIn->CbMax;
	CoefOut->CbMin = CoefIn->CbMin;
	CoefOut->CrMax = CoefIn->CrMax;
	CoefOut->CrMin = CoefIn->CrMin;
	return RetVal;
}
u32 XRgb2YCrCb_Coefficient_Translation ( XRgb2YCrCb * InstancePtr , struct XRgb2YCrCb_Coef_Inputs * CoefIn , struct XRgb2YCrCb_Coef_Outputs * CoefOut , u32 DataWidth ) { u32 RetVal = 0 ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( CoefIn != NULL ) ; Xil_AssertNonvoid ( CoefOut != NULL ) ; Xil_AssertNonvoid ( ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_16 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_10 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_12 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_8 ) ) ) ; if ( ( CoefIn -> ACoef + CoefIn -> BCoef ) > ( 1.0 ) ) { RetVal = ( RetVal ) | ( 0x1 ) ; } if ( ( ( ( int ) CoefIn -> YOffset ) < ( ( int ) - ( 1 << DataWidth ) ) ) || ( ( ( int ) CoefIn -> YOffset ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) ) { RetVal = ( RetVal ) | ( 0x2 ) ; } if ( ( ( ( int ) CoefIn -> CbOffset ) < ( ( int ) - ( 1 << DataWidth ) ) ) || ( ( ( int ) CoefIn -> CbOffset ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) ) { RetVal = ( RetVal ) | ( 0x4 ) ; } if ( ( ( ( int ) CoefIn -> CrOffset ) < ( ( int ) - ( 1 << DataWidth ) ) ) || ( ( ( int ) CoefIn -> CrOffset ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) ) { RetVal = ( RetVal ) | ( 0x8 ) ; } if ( ( ( int ) CoefIn -> YMax ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x10 ) ; } if ( ( ( int ) CoefIn -> YMin ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x20 ) ; } if ( ( ( int ) CoefIn -> CbMax ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x40 ) ; } if ( ( ( int ) CoefIn -> CbMin ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x80 ) ; } if ( ( ( int ) CoefIn -> CrMax ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x100 ) ; } if ( ( ( int ) CoefIn -> CrMin ) > ( ( int ) ( ( 1 << DataWidth ) - 1 ) ) ) { RetVal = ( RetVal ) | ( 0x200 ) ; } CoefOut -> ACoef = CoefIn -> ACoef * ( 1 << 16 ) ; CoefOut -> BCoef = CoefIn -> BCoef * ( 1 << 16 ) ; CoefOut -> CCoef = CoefIn -> CCoef * ( 1 << 16 ) ; CoefOut -> DCoef = CoefIn -> DCoef * ( 1 << 16 ) ; CoefOut -> YOffset = CoefIn -> YOffset ; CoefOut -> CbOffset = CoefIn -> CbOffset ; CoefOut -> CrOffset = CoefIn -> CrOffset ; CoefOut -> YMax = CoefIn -> YMax ; CoefOut -> YMin = CoefIn -> YMin ; CoefOut -> CbMax = CoefIn -> CbMax ; CoefOut -> CbMin = CoefIn -> CbMin ; CoefOut -> CrMax = CoefIn -> CrMax ; CoefOut -> CrMin = CoefIn -> CrMin ; return RetVal ; }
This function translates the XRgb2YCrCb_Coef_Inputs structure into the
XRgb2YCrCb_Coef_Outputs structure that can be used to program the core's
registers.
This function translates the XRgb2YCrCb_Coef_Inputs structure into the XRgb2YCrCb_Coef_Outputs structure that can be used to program the core ' s registers .
/* Verify arguments. */