⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agl_conv.h

📁 TI公司的算法标准 Framework5的源代码
💻 H
字号:
	/*! \verbatim
==============================================================================
                     Copyright (C) 2002 A.T.E.M.E.
                          All Rights Reserved
------------------------------------------------------------------------------
 MODULE NAME... AGL_CONV
 FILENAME...... agl_conv.h
 PROJECT....... AGL
------------------------------------------------------------------------------
 HISTORY:
 V1.0    19/02/2002  TSO
         01/07/2002  MME
------------------------------------------------------------------------------
\endverbatim <P> \file

\brief Header file for conversion functions

</P>*//*====================================================================*/

#ifndef __AGL_CONV_H__
#define __AGL_CONV_H__

#ifdef __cplusplus
extern "C" {
#endif

/*=======================================================================*//*!
\defgroup CONV CONV - Video pixel format conversion module

	This module provides useful format conversion functions for C6x and win32 target.
	
</P>*//*==============================================================*//*@{*/

/*! 
	This variable defines the typical color-space-conversion matrix coefficients.
	The coefficients are in signed Q13 form. These coefficients correspond to the 
	following matrix equation:   <BR>  
	           		coeff[] = { 0x2543, 0x3313, -0x0C8A, -0x1A04, 0x408D };<BR>
<BR>	           		
		           [ 1.1644    0.0000    1.5960 ]   [ Y' -  16 ]     [ R']<BR>
		           [ 1.1644   -0.3918   -0.8130 ] * [ Cb - 128 ]  =  [ G']<BR>
		           [ 1.1644    2.0172    0.0000 ]   [ Cr - 128 ]     [ B']<BR>
<BR>	           		
*/
extern const Int16 CONV_RgbCoef[];

/*--------------------------------------------------------------------------*/
/*! Convert a graphical YUY2 frame (YUV422) into a IYUV frame (YUV420)

	Original C64x code provided by courtesy of Texas Instruments ( Copyright (c) 2002 
	Texas Instruments, Incorporated).

	\param pYUY2
				A pointer to a YUY2 frame. This array must be an interleaved 4:2:2 video 
				stream.	Pixels must be organized in the following way :
<BR>                  <BR>                    
	              | y0 u0 y1 v0 | y2 u2 y3 v2 | y4 u4 y5 v4 |...<BR>
<BR>
		
	\param width
				Width of the input frame.
				
	\param height
				Height of the input frame.

	\param pYOut
				A pointer to a Luma plane.

	\param pUOut
				A pointer to a U plane.

  	\param pVOut
				A pointer to a V plane.

	\return	Nothing
	
	<dl>
	<b> TMS320C64XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYOut, pYUY2  must be be double-word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = 5 * (height * (width / 16)) + 17.<BR>
	       	For height = 288 and width = 352, cycles = 31697				
	</dl>
	
	<dl>
	<b> TMS320C62XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYOut, pYUY2  must be be word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = (((height / 2) *((width / 8) *40 + 76)) + 58.<BR>
	       	For height = 288 and width = 352, cycles = 264442				
	</dl>
	
	<dl>
	<b> WIN32 platform:</b> <BR> 
	<dd> No Assumptions.
	</dl>

				
	\b Example: 
	\verbatim

	Uint32 width=352;
	Uint32 height=288;

	// allocate a YUY2 buffer
	Uint8 *pInputBuffer = malloc( width * height *2 );
	
	// allocate IYUV buffers
	Uint8 *pY = malloc( width * height );
	Uint8 *pU = malloc( width * height / 4 );
	Uint8 *pV = malloc( width * height / 4 );
		
	// fill the input frame
	
	CONV_YUY2toIYUV((const Uint16*)pInputBuffer, width, height, 
		(Uint16 *)pY, (Uint16 *)pU, (Uint16 *)pV);
	
	\endverbatim

*/
void CONV_YUY2toIYUV (const Uint16 *pYUY2, Int16 width, Int16 height,
					 Uint16 *pYOut, Uint16 *pUOut, Uint16 *pVOut);

/*--------------------------------------------------------------------------*/

/*! Convert a graphical IYUV frame (YUV420) into a YUY2 frame (YUV422).
 
	\param pYUY2
				A pointer to a IYUY frame.

	\param pYIn
				A pointer to a Luma plane.

	\param pUIn
				A pointer to a U plane.

  	\param pVIn
				A pointer to a V plane.

	\param width
				Width of the input frame
				
	\param height
				Height of the input frame

	\param pitch
				Width in bytes of the output frame

	\return	Nothing

	<dl>
	<b> TMS320C64XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYUY2, pYIn, pUIn, pVIn must be be double-word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = (9 * height * (width / 16)) + 95.<BR>
	       	For height = 288 and width = 352, cycles = 57119				
	</dl>
	
	<dl>
	<b> TMS320C62XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYUY2, pYIn, pUIn, pVIn must be be word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = (((height / 2) * (43 + (width / 8) * 82)) + 40 .<BR>
	       	For height = 288 and width = 352, cycles = 525784				
	</dl>
	
	<dl>
	<b> WIN32 platform:</b> <BR> 
	<dd> No Assumptions.
	</dl>
	
			
	\b Example: 
	\verbatim
	
	Uint32 width=352;
	Uint32 height=288;

	// allocate a YUY2 buffer
	Uint8 *pOutputBuffer = malloc( width * height *2 );
	
	// allocate IYUV buffers
	Uint8 *pY = malloc( width * height );
	Uint8 *pU = malloc( width * height / 4 );
	Uint8 *pV = malloc( width * height / 4 );
		
	// fill the input frame
	
	CONV_IYUVtoYUY2((void *)pOutputBuffer, (const void *)pY, (const void *)pU, 
			(const void *)pV, width, height, width * 2);
	\endverbatim
*/
void CONV_IYUVtoYUY2(void *pYUY2, const void *pYIn, const void *pUIn, const void *pVIn, 
							const Uint32 width, const Uint32 height, Uint32 pitch);

/*--------------------------------------------------------------------------*/

/*! Convert a graphical YUY2 frame (YUV422) into a RGB 32 bits color space.

	\param ptrOut
				A pointer to a RGB buffer. Pixels are organized in the following way:
<BR>                  <BR>                    
				| 0 B0 G0 R0 | 0 B1 G1 R1 |... <BR>
<BR>
	\param ptrIn
				A pointer to a YUY2 frame. This array must be an interleaved 4:2:2 video 
				stream.	Pixels must be organized in the following way :
<BR>                  <BR>                    
	              | y0 u0 y1 v0 | y2 u2 y3 v2 | y4 u4 y5 v4 |...<BR>
<BR>

	\param width
				Width of the input frame
				
	\param height
				Height of the input frame

	\return	Nothing


	<dl>
	<b> TMS320C64XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	ptrOut must be be double-word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = (13 * (height * (wifth / 4)) + 109.<BR>
	       	For height = 288 and width = 352, cycles = 329581 				
	</dl>
	
	<dl>
	<b> TMS320C62XX platform:</b> <BR> 
	<dd>	Not yet supported
	</dl>
	
	<dl>
	<b> WIN32 platform:</b> <BR> 
	<dd>	Not yet supported
	</dl>
	
	\b Example: 
	\verbatim
	
	Uint32 width=352;
	Uint32 height=288;

	// allocate a YUY2 buffer
	Uint8 *pInputBuffer = malloc( width * height *2 );
	
	// allocate RGB buffer
	Uint32 *pRGBBuffer = malloc( width * height );

	// fill the input frame
	
	CONV_YUV2toRGB32(pInputBuffer, pRGBBuffer, width, height);
	
	\endverbatim
*/
void CONV_YUV2toRGB32(void *ptrOut, const void *ptrIn, 
					const Uint32 width, const Uint32 height);

/*--------------------------------------------------------------------------*/

/*! Convert a graphical IYUV frame (YUV422) into a RGB 16 bits color space.

	Original C64x code provided by courtesy of Texas Instruments ( Copyright (c) 2002 
	Texas Instruments, Incorporated).
		
	\param coeff
				A pointer to the color-space-conversion matrix coefficients. The 
				coefficients must be in signed Q13 form. These coefficients 
				correspond to the following matrix equation:   <BR>  
<BR>				
		           [ coeff[0] 0.0000   coeff[1] ]   [ Y' -  16 ]     [ R']<BR>
		           [ coeff[0] coeff[2] coeff[3] ] * [ Cb - 128 ]  =  [ G']<BR>
		           [ coeff[0] coeff[4] 0.0000   ]   [ Cr - 128 ]     [ B']   <BR> 
<BR>		                	           
				Typical values:				<BR>
<BR>				
				Typical values are defined in CONV_RgbCoef variable.

		
	\param pYIn
				A pointer to luminance data.

	\param pUIn
				A pointer to chrominace data (U).
				
	\param pVIn
				A pointer to chrominace data (V).

	\param pRgbOut
				A pointer to the output image buffer.

	\param num_pixels
				Number of luma pixels to process. The number of luma samples to be 
				processed 
				needs to be a multiple of 8.

	\return	Nothing


	<dl>
	<b> TMS320C64XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYIn,pRgbOut  must be be double-word aligned. <BR>
			pUIn and pVIn must be word aligned. <BR> 
			\li \b Cycles: <BR>
	<dd>	cycles = (12 * height * (width / 8)) + 50.<BR>
	       	For height = 288 and width = 352, cycles = 152114				
	</dl>
	
	<dl>
	<b> TMS320C62XX platform:</b> <BR> 
	<dd>	Not yet supported.
	</dl>
	
	<dl>
	<b> WIN32 platform:</b> <BR> 
	<dd>	Not yet supported.
	</dl>

			
	\b Example: 
	\verbatim
	
	Uint32 width=352;
	Uint32 height=288;

	// allocate IYUV buffers
	Uint8 *pY = malloc( width * height );
	Uint8 *pU = malloc( width * height / 4 );
	Uint8 *pV = malloc( width * height / 4 );
	
	// allocate RGB buffer
	Uint16 *pRGBBuffer = malloc( width * height );

	// fill the input frame
	
	CONV_IYUV422toRGB16(CONV_RgbCoef, (const Uint8*)pY, (const Uint8*)pU, 
		(const Uint8*)pV, (Uint16 *)pRGBBuffer, (unsigned) width * height);
	
	\endverbatim
*/

void CONV_IYUV422toRGB16 ( const Int16 coeff[5], const Uint8 *pYIn, const Uint8 *pUIn,
						const Uint8 *pVIn, Uint16 *pRgbOut, unsigned num_pixels);


/*--------------------------------------------------------------------------*/

/*! Convert a graphical IYUV frame (YUV420) into a RGB 16 bits color space.

	Original C64x code provided by courtesy of Texas Instruments ( Copyright (c) 2002 
	Texas Instruments, Incorporated).
	
	\param coeff
				A pointer to the color-space-conversion matrix coefficients. The 
				coefficients must be in signed Q13 form. These coefficients 
				correspond to the following matrix equation:   <BR>  
<BR>				
		           [ coeff[0] 0.0000   coeff[1] ]   [ Y' -  16 ]     [ R']<BR>
		           [ coeff[0] coeff[2] coeff[3] ] * [ Cb - 128 ]  =  [ G']<BR>
		           [ coeff[0] coeff[4] 0.0000   ]   [ Cr - 128 ]     [ B']   <BR> 
<BR>		                	           
				Typical values are defined in CONV_RgbCoef variable.
		
	\param pYIn
				A pointer to luminance data, it must be double-word aligned.

	\param pUIn
				A pointer to chrominace data (U), it must be word aligned.
				
	\param pVIn
				A pointer to chrominace data (V), it must be word aligned.

	\param pRgbOut
				A pointer to the output image buffer, it must be double-word aligned.

	\param width
				Width of the input frame
				
	\param height
				Height of the input frame

	\return	Nothing


	<dl>
	<b> TMS320C64XX platform:</b> <BR> 
			\li \b Assumptions: <BR>
	<dd>	pYIn, pRgbOut  must be be double-word aligned. <BR>
			pUIn and pVIn must be word aligned. 
			\li \b Cycles: <BR>
	<dd>	height * ( 12 * (width)/8 + 97) + 15. <BR>
	       	For width = 288 and height = 352, cycles = 152114
	</dl>
	
	<dl>
	<b> TMS320C62XX platform:</b> <BR> 
	<dd>	Not yet supported.
	</dl>
	
	<dl>
	<b> WIN32 platform:</b> <BR> 
	<dd>	Not yet supported.
	</dl>
	
	\b Example: 
	\verbatim
	
	Uint32 width=352;
	Uint32 height=288;

	// allocate IYUV buffers
	Uint8 *pY = malloc( width * height );
	Uint8 *pU = malloc( width * height / 4 );
	Uint8 *pV = malloc( width * height / 4 );
	
	// allocate RGB buffer
	Uint16 *pRGBBuffer = malloc( width * height );

	// fill the input frame
	
	CONV_IYUVtoRGB16(CONV_RgbCoef, (const Uint8*)pY, (const Uint8*)pU, 
		(const Uint8*)pV, (Uint16 *)pRGBBuffer, width, height);
	
	\endverbatim
*/

void CONV_IYUVtoRGB16(const Int16 coeff[5], const void *pYIn, const void *pUIn, const void *pVIn, 
						Uint16 *pRgbOut, const Uint32 width, const Uint32 height);

/*@}*//* end of group CONV */
#ifdef __cplusplus
}
#endif
						
#endif


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -