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

📄 g72x.h

📁 基于TI的DSP的G726_CODEC
💻 H
字号:
/* * This source code is a product of Sun Microsystems, Inc. and is provided * for unrestricted use.  Users may copy or modify this source code without * charge. * * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun source code is provided with no support and without any obligation on * the part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California  94043 *//* * g72x.h * * Header file for CCITT conversion routines. * */static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,			0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};  			#ifndef _G72X_H#define	_G72X_H/*#define	AUDIO_ENCODING_LINEAR	(3)	/ PCM 2's-complement (0-center) *//* * The following is the definition of the state structure * used by the G.721/G.723 encoder and decoder to preserve their internal * state between successive calls.  The meanings of the majority * of the state structure fields are explained in detail in the * CCITT Recommendation G.721.  The field names are essentially indentical * to variable names in the bit level description of the coding algorithm * included in this Recommendation. */struct g72x_state {	long yl;	/* Locked or steady state step size multiplier. */	short yu;	/* Unlocked or non-steady state step size multiplier. */	short dms;	/* Short term energy estimate. */	short dml;	/* Long term energy estimate. */	short ap;	/* Linear weighting coefficient of 'yl' and 'yu'. */	short a[2];	/* Coefficients of pole portion of prediction filter. */	short b[6];	/* Coefficients of zero portion of prediction filter. */	short pk[2];	/*			 * Signs of previous two samples of a partially			 * reconstructed signal.			 */	short dq[6];	/*			 * Previous 6 samples of the quantized difference			 * signal represented in an internal floating point			 * format.			 */	short sr[2];	/*			 * Previous 2 samples of the quantized difference			 * signal represented in an internal floating point			 * format.			 */	char td;	/* delayed tone detect, new in 1988 version */};/* External function definitions. */extern void g72x_init_state(struct g72x_state *);/*extern int predictor_zero(struct g72x_state *state_ptr); *//*extern int predictor_pole(struct g72x_state *state_ptr); */extern int step_size(struct g72x_state *state_ptr);extern int quantize(int	d, int y, short *table);extern int reconstruct(int sign, int dqln, int y);extern void update(int code_size, long y, long wi, int fi, int dq, int sr, int dqsez, struct g72x_state *state_ptr);extern int g721_encoder(		int sample,		struct g72x_state *state_ptr);extern int g721_decoder(		int code,		struct g72x_state *state_ptr);                                                                                                                                                                        /*qune set inline */#ifdef _INLINE#define __INLINE static inline#else#define __INLINE#endif__INLINE int fmult(int	an,int	srn);__INLINE int quan7(int	val,short	*table);__INLINE int quan16(int	val,short	*table);#ifdef _INLINE/* * fmult() * * returns the integer product of the 14-bit integer "an" and * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn". */static inline intfmult(	int		an,	int		srn){	short		anmag, anexp, anmant;	long		wanexp/*, wanmag*/, wanmant;	short		retval;	anmag = (an > 0) ? an : ((-an) & 0x1FFF);	anexp = quan16(anmag, power2) - 6;	anmant = (anmag == 0) ? 32 :	    (anexp >= 0) ? anmag >> anexp : anmag << -anexp;	wanexp = anexp + ((srn >> 6) & 0xF) - 13;	wanmant = (anmant * (srn & 077) + 0x30) >> 4;	retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :	    (wanmant >> -wanexp);	return (((an ^ srn) < 0) ? -retval : retval);}static inline int quan7(int	val,short	*table){	int		i;                                       	for (i = 0; i < size; i++)		if (val < *table++)			break;	return (i);}#endif  /* INLINE */#undef __INLINE	#endif /* !_G72X_H */

⌨️ 快捷键说明

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