XilinxProcessorIPLib/drivers/rgb2ycrcb/src/xrgb2ycrcb.c
void XRgb2YCrCb_Select_Standard(XRgb2YCrCb *InstancePtr,
				enum XRgb_Standards StandardSel,
				enum XRgb_OutputRanges InputRange, u32 DataWidth,
				struct XRgb2YCrCb_Coef_Inputs *CoefIn)
{
	/* Verify arguments. */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(CoefIn != NULL);
	Xil_AssertVoid((DataWidth == (u32)(XRGB_DATA_WIDTH_16))  ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_10)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_12)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_8)));

	Xil_AssertVoid(StandardSel <(u32)(XRGB_STANDARD_CUSTOM));
	Xil_AssertVoid(InputRange <= (u32)(XRGB_GRAPHICS_0_TO_255));

	double ACoef[4][3] = {
				{0.299, 0.299,  0.2568},
				{0.299, 0.299,  0.2568},
				{0.2126, 0.2126, 0.1819},
				{0.299, 0.299, 0.299}
			};

	double BCoef[4][3] = {
				{0.114, 0.114,  0.0979},
				{0.114, 0.114,  0.0979},
				{0.0722, 0.0722, 0.0618},
				{0.114, 0.114, 0.114}
			};

	double CCoef[4][3] = {
				{0.713, 0.7295, 0.5910},
				{0.713, 0.7295, 0.5910},
				{0.6350, 0.6495, 0.6495},
				{0.877283, 0.877283, 0.877283}
			};

	double DCoef[4][3] = {
				{0.564, 0.5772, 0.5772},
				{0.564, 0.5772, 0.5772},
				{0.5389, 0.5512, 0.5512},
				{0.492111, 0.492111, 0.492111}
			};

	u32 Max[3] = {
			(240 * (1 << (DataWidth - 8))),
			(235 * (1 << (DataWidth - 8))),
			((1 << DataWidth) - 1)
		};
	u32 Min[3] = {
			(16 * (1 << (DataWidth - 8))),
			(16 * (1 << (DataWidth - 8))),
			0
		};

	u32 YOffset = (1 << (DataWidth - 4));
	u32 COffset = (u32)(1 << (DataWidth - 1));

	CoefIn->ACoef = ACoef[StandardSel][InputRange];
	CoefIn->BCoef = BCoef[StandardSel][InputRange];
	CoefIn->CCoef = CCoef[StandardSel][InputRange];
	CoefIn->DCoef = DCoef[StandardSel][InputRange];

	CoefIn->YOffset  = YOffset;
	CoefIn->CbOffset = COffset;
	CoefIn->CrOffset = COffset;

	CoefIn->YMax = Max[InputRange];
	CoefIn->YMin = Min[InputRange];
	CoefIn->CbMax = Max[InputRange];
	CoefIn->CbMin = Min[InputRange];
	CoefIn->CrMax = Max[InputRange];
	CoefIn->CrMin = Min[InputRange];
}
/*****************************************************************************/
/**
*
* This function populates an XRgb2YCrCb_Coef_Inputs structure with the values
* from the selected video standard.
*
* @param	InstancePtr is a pointer to the XRgb2YCrCb instance.
* @param	StandardSel needs to be set from enum XRgb_Standards value as :
*		0 = XRGB_STANDARD_ITU_601_SD
*		1 = XRGB_STANDARD_ITU_709_NTSC
*		2 = XRGB_STANDARD_ITU_709_PAL
*		3 = XRGB_STANDARD_YUV.
* @param	InputRange needs to be set from enum OutputRanges value as:
*		0 = XRGB_TV_16_TO_240,
*		1 = XRGB_STUDIO_16_TO_235,
*		2 = XRGB_GRAPHICS_0_TO_255.
* @param	DataWidth specifies the valid range of [8,10,12,16] that needs
*		to be set.
* @param	CoefIn specifies a pointer to a XRgb2YCrCb_Coef_Inputs
*		structure which is populated with the values from selected
*		video standard.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
This function populates an XRgb2YCrCb_Coef_Inputs structure with the values
from the selected video standard.
This function populates an XRgb2YCrCb_Coef_Inputs structure with the values from the selected video standard .
void XRgb2YCrCb_Select_Standard(XRgb2YCrCb *InstancePtr,
				enum XRgb_Standards StandardSel,
				enum XRgb_OutputRanges InputRange, u32 DataWidth,
				struct XRgb2YCrCb_Coef_Inputs *CoefIn)
{
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(CoefIn != NULL);
	Xil_AssertVoid((DataWidth == (u32)(XRGB_DATA_WIDTH_16))  ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_10)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_12)) ||
			(DataWidth == (u32)(XRGB_DATA_WIDTH_8)));
	Xil_AssertVoid(StandardSel <(u32)(XRGB_STANDARD_CUSTOM));
	Xil_AssertVoid(InputRange <= (u32)(XRGB_GRAPHICS_0_TO_255));
	double ACoef[4][3] = {
				{0.299, 0.299,  0.2568},
				{0.299, 0.299,  0.2568},
				{0.2126, 0.2126, 0.1819},
				{0.299, 0.299, 0.299}
			};
	double BCoef[4][3] = {
				{0.114, 0.114,  0.0979},
				{0.114, 0.114,  0.0979},
				{0.0722, 0.0722, 0.0618},
				{0.114, 0.114, 0.114}
			};
	double CCoef[4][3] = {
				{0.713, 0.7295, 0.5910},
				{0.713, 0.7295, 0.5910},
				{0.6350, 0.6495, 0.6495},
				{0.877283, 0.877283, 0.877283}
			};
	double DCoef[4][3] = {
				{0.564, 0.5772, 0.5772},
				{0.564, 0.5772, 0.5772},
				{0.5389, 0.5512, 0.5512},
				{0.492111, 0.492111, 0.492111}
			};
	u32 Max[3] = {
			(240 * (1 << (DataWidth - 8))),
			(235 * (1 << (DataWidth - 8))),
			((1 << DataWidth) - 1)
		};
	u32 Min[3] = {
			(16 * (1 << (DataWidth - 8))),
			(16 * (1 << (DataWidth - 8))),
			0
		};
	u32 YOffset = (1 << (DataWidth - 4));
	u32 COffset = (u32)(1 << (DataWidth - 1));
	CoefIn->ACoef = ACoef[StandardSel][InputRange];
	CoefIn->BCoef = BCoef[StandardSel][InputRange];
	CoefIn->CCoef = CCoef[StandardSel][InputRange];
	CoefIn->DCoef = DCoef[StandardSel][InputRange];
	CoefIn->YOffset  = YOffset;
	CoefIn->CbOffset = COffset;
	CoefIn->CrOffset = COffset;
	CoefIn->YMax = Max[InputRange];
	CoefIn->YMin = Min[InputRange];
	CoefIn->CbMax = Max[InputRange];
	CoefIn->CbMin = Min[InputRange];
	CoefIn->CrMax = Max[InputRange];
	CoefIn->CrMin = Min[InputRange];
}
void XRgb2YCrCb_Select_Standard ( XRgb2YCrCb * InstancePtr , enum XRgb_Standards StandardSel , enum XRgb_OutputRanges InputRange , u32 DataWidth , struct XRgb2YCrCb_Coef_Inputs * CoefIn ) { Xil_AssertVoid ( InstancePtr != NULL ) ; Xil_AssertVoid ( CoefIn != NULL ) ; Xil_AssertVoid ( ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_16 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_10 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_12 ) ) || ( DataWidth == ( u32 ) ( XRGB_DATA_WIDTH_8 ) ) ) ; Xil_AssertVoid ( StandardSel < ( u32 ) ( XRGB_STANDARD_CUSTOM ) ) ; Xil_AssertVoid ( InputRange <= ( u32 ) ( XRGB_GRAPHICS_0_TO_255 ) ) ; double ACoef [ 4 ] [ 3 ] = { { 0.299 , 0.299 , 0.2568 } , { 0.299 , 0.299 , 0.2568 } , { 0.2126 , 0.2126 , 0.1819 } , { 0.299 , 0.299 , 0.299 } } ; double BCoef [ 4 ] [ 3 ] = { { 0.114 , 0.114 , 0.0979 } , { 0.114 , 0.114 , 0.0979 } , { 0.0722 , 0.0722 , 0.0618 } , { 0.114 , 0.114 , 0.114 } } ; double CCoef [ 4 ] [ 3 ] = { { 0.713 , 0.7295 , 0.5910 } , { 0.713 , 0.7295 , 0.5910 } , { 0.6350 , 0.6495 , 0.6495 } , { 0.877283 , 0.877283 , 0.877283 } } ; double DCoef [ 4 ] [ 3 ] = { { 0.564 , 0.5772 , 0.5772 } , { 0.564 , 0.5772 , 0.5772 } , { 0.5389 , 0.5512 , 0.5512 } , { 0.492111 , 0.492111 , 0.492111 } } ; u32 Max [ 3 ] = { ( 240 * ( 1 << ( DataWidth - 8 ) ) ) , ( 235 * ( 1 << ( DataWidth - 8 ) ) ) , ( ( 1 << DataWidth ) - 1 ) } ; u32 Min [ 3 ] = { ( 16 * ( 1 << ( DataWidth - 8 ) ) ) , ( 16 * ( 1 << ( DataWidth - 8 ) ) ) , 0 } ; u32 YOffset = ( 1 << ( DataWidth - 4 ) ) ; u32 COffset = ( u32 ) ( 1 << ( DataWidth - 1 ) ) ; CoefIn -> ACoef = ACoef [ StandardSel ] [ InputRange ] ; CoefIn -> BCoef = BCoef [ StandardSel ] [ InputRange ] ; CoefIn -> CCoef = CCoef [ StandardSel ] [ InputRange ] ; CoefIn -> DCoef = DCoef [ StandardSel ] [ InputRange ] ; CoefIn -> YOffset = YOffset ; CoefIn -> CbOffset = COffset ; CoefIn -> CrOffset = COffset ; CoefIn -> YMax = Max [ InputRange ] ; CoefIn -> YMin = Min [ InputRange ] ; CoefIn -> CbMax = Max [ InputRange ] ; CoefIn -> CbMin = Min [ InputRange ] ; CoefIn -> CrMax = Max [ InputRange ] ; CoefIn -> CrMin = Min [ InputRange ] ; }
This function populates an XRgb2YCrCb_Coef_Inputs structure with the values
from the selected video standard.
This function populates an XRgb2YCrCb_Coef_Inputs structure with the values from the selected video standard .
/* Verify arguments. */