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

📄 g723_func.c

📁 G.723在ARM上的实现。实现平台为Linux2.4.8+ Intel Xscal。包括源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	*/	int j;	Ipp16s iTemp1, iTemp2;	/* Derive pitch synchronous filter from modified closed-loop pitch lag and gain */	iTemp1 = OpenLoopPitchLag - 1 + ClosedLoopPitchOffset + pitchSyncFiltLagTable[AdaptGainIndex];	iTemp2 = pitchSyncFiltGainTable[AdaptGainIndex];	for ( j = 0; j < IPP_G723_SUBFRAME_LEN; j ++ )		pSrcDstImpulseResp[j] >>= 1;	/* Apply pitch synchronous filter only for pitch lags < 60 */	if ( iTemp1 < IPP_G723_SUBFRAME_LEN-2 )										for ( j = iTemp1; j < IPP_G723_SUBFRAME_LEN; j ++ )			pSrcDstImpulseResp[j] += (Ipp16s)(((Ipp32s)pSrcDstImpulseResp[j-iTemp1] * iTemp2) >> 15);	*pitchSyncIndex = iTemp1;	*pitchSyncGain = iTemp2;		return(IPP_STATUS_OK);	} /* appsPitchSyncFilter_G723_16s_I */IppStatus	appsScaleACELPVector_G723_16s_I(Ipp16s *pSrcDstAdaptCbVect,                                             Ipp16s QuantGain, 						         			Ipp16s pitchSyncIndex,											Ipp16s pitchSyncGain){	int j;	/* Apply gain to ACELP vector */	for ( j = 0; j < IPP_G723_SUBFRAME_LEN; j ++ )		pSrcDstAdaptCbVect[j] = (Ipp16s)((Ipp32s)pSrcDstAdaptCbVect[j] * QuantGain);	if ( pitchSyncIndex < IPP_G723_SUBFRAME_LEN-2 )		for ( j = pitchSyncIndex; j < IPP_G723_SUBFRAME_LEN; j ++ )			pSrcDstAdaptCbVect[j] += (Ipp16s)(((Ipp32s)pSrcDstAdaptCbVect[j-pitchSyncIndex] * pitchSyncGain) >> 15);	return(IPP_STATUS_OK);	} /* appsScaleFixedVector_G723_16s */IppStatus	appsPackBitstream_G723_8u(Ipp8u *pDstBitStream, 									  int *pDstNumBitstreamBytes,									  Ipp32s quantLsfIndex, 									  Ipp16s *adaptCbLagAbs,									  Ipp16s *adaptCbLagDiff,									  Ipp16s *adaptCbGainIndex,									  Ipp16s *fixedCbGainIndex,									  Ipp16s *fixedCbDiracPulseFlag,									  Ipp16s *fixedCbGridAlign,									  Ipp32s *fixedCbPulsePos,									  Ipp16s *fixedCbPulseSign,									  Ipp16s *frameTypeHistory,									  Ipp16s frameType,									  IppSpchBitRate bitRate){	int i,j;	Ipp16s iTemp1, iTemp2;	Ipp8u  iBitStream[_G723_STREAM_BYTES_63KBPS<<3];	/* expanded bitstream buffer - 1 stream bit per 8-bit word */	Ipp8u  *pTemp1;										/* raw bitstream pointer used for stream synthesis */		/* For the encoded frame, generate an uncompressed bitstream for in the buffer iBitStream[].	   Represent each stream bit using a single 8-bit byte (Ipp8u).	 */	pTemp1 = iBitStream;	/* Bit 0: RATEFLAG_B0 - 0=6.3 kbps, 1=5.3 kbps for VAD==1, or 1=NonTx, 0=SID for VAD==0 */ 	* pTemp1++ = (Ipp8u)(((bitRate==IPP_SPCHBR_5300)&&(frameType==1))||(frameType==0));	/* Bit 1: VADFLAG_B0 - 0=speech, 1=non-speech */	* pTemp1++ = (Ipp8u)((frameType==0)||(frameType==2));	// 0=nonTX, 1=active speech (VAD==1), 2=SID (VAD==0)	switch(frameType)	{		/* NonTX */		case 0:			/* Bits 2-7: zero-pad 1 byte for nonTX frame */			for ( i = 0; i < 6; i++ )				* pTemp1++ = 0;			break;		case 2:			/* Bits 2-25:  LPC parameters (quantized LSFs) */			for ( i = 0; i < 24; i ++ )				* pTemp1++ = (Ipp8u)((quantLsfIndex >> i) & 1);			/* Bits 26-30: CNG Gain */			for ( i = 0; i < 6; i ++ )			{				* pTemp1++ = (Ipp8u)((fixedCbGainIndex[0] >> i) & 1);			}			break;		case 1:			/* Bits 2-25:  LPC parameters (quantized LSFs) */			for ( i = 0; i < 24; i ++ )				* pTemp1++ = (Ipp8u)((quantLsfIndex >> i) & 1);			/* Bits 26-32: 7-bit adaptive codeboook lag, subframe 0 */			iTemp1 = adaptCbLagAbs[0] - 18;			for ( i = 0; i < 7; i ++ )				* pTemp1++ = (Ipp8u)((iTemp1 >> i) & 1);			/* Bits 33-34: 2-bit adaptive codeboook lag (differential), subframe 1 */			for ( i = 0; i < 2; i ++ )				* pTemp1++ = (Ipp8u)((adaptCbLagDiff[1] >> i) & 1);			/* Bits 35-41: 7-bit adaptive codeboook lag, subframe 2 */			iTemp1 = adaptCbLagAbs[2] - 18;			for ( i = 0; i < 7; i ++ )				* pTemp1++ = (Ipp8u)((iTemp1 >> i) & 1);			/* Bits 42-43: 2-bit adaptive codeboook lag (differential), subframe 3 */			for ( i = 0; i < 2; i ++ )				* pTemp1++ = (Ipp8u)((adaptCbLagDiff[3] >> i) & 1);			/* Bits 44-91: 48 bits of encoded gains, 12-bits per subframe */			/* Dirac pulse train indicator bits included for 6.3 kbps mode */			for ( i = 0; i < IPP_G723_NUM_SUBFRAME; i ++ )			{				iTemp1 = adaptCbGainIndex[i] * 24 + fixedCbGainIndex[i];				if ( bitRate == IPP_SPCHBR_6300 )					iTemp1 += (fixedCbDiracPulseFlag[i] << 11);				for ( j = 0; j < 12; j ++ )					* pTemp1++ = (Ipp8u)((iTemp1 >> j) & 1);			}			/* Bits 92-95:  Grid position bits for subframes 0-3 */			for ( i = 0; i < 4; i ++ )				* pTemp1++ = (Ipp8u)fixedCbGridAlign[i];			/* Format pulse position and pulse sign parameters */			/* 6.3 kbps mode */			if ( bitRate == IPP_SPCHBR_6300 )			{					/* Combine 4 most significant bits from subframes 0-3 to form 13-bit index */				* pTemp1++ = 0;				iTemp1 = (Ipp16s)(fixedCbPulsePos[0] >> 16);				iTemp1 = iTemp1 * 9 + (Ipp16s)(fixedCbPulsePos[1] >> 14);				iTemp1 = iTemp1 * 90 + (Ipp16s)(fixedCbPulsePos[2] >> 16) * 9;				iTemp1 = iTemp1 + (Ipp16s)(fixedCbPulsePos[3] >> 14);				/* Bits 96-108:  Combined 13-bit pulse position index for subframes 0-3 */				for ( i = 0; i < 13; i ++ )					* pTemp1++ = (Ipp8u)((iTemp1 >> i) & 1);				/* Bits 109-124: Pulse position bits for 6 pulses, subframe 0 */					for ( i = 0; i < 16; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulsePos[0] >> i) & 1);				/* Bits 125-138: Pulse position bits for 5 pulses, subframe 1 */					for ( i = 0; i < 14; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulsePos[1] >> i) & 1);				/* Bits 139-154: Pulse position bits for 6 pulses, subframe 2 */					for ( i = 0; i < 16; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulsePos[2] >> i) & 1);				/* Bits 155-168: Pulse position bits for 5 pulses, subframe 3 */					for ( i = 0; i < 14; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulsePos[3] >> i) & 1);				/* Bits 169-174: Pulse sign bits for 6 pulses, subframe 0 */				for ( i = 0; i < 6; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulseSign[0] >> i) & 1);				/* Bits 175-179: Pulse sign bits for 5 pulses, subframe 1 */				for ( i = 0; i < 5; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulseSign[1] >> i) & 1);				/* Bits 180-185: Pulse sign bits for 6 pulses, subframe 2 */				for ( i = 0; i < 6; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulseSign[2] >> i) & 1);				/* Bits 186-190: Pulse sign bits for 5 pulses, subframe 3 */				for ( i = 0; i < 5; i ++ )					* pTemp1++ = (Ipp8u)((fixedCbPulseSign[3] >> i) & 1);			} 			else			/* 5.3 kbps mode */			{				/* Bits 96-143: Pulse position bits for subframes 0-3 */				for ( i = 0; i < IPP_G723_NUM_SUBFRAME; i ++ )					for ( j = 0; j < 12; j ++ )						*pTemp1++ = (Ipp8u)((fixedCbPulsePos[i] >> j) & 1);				/* Bits 144-159: Pulse sign bits for subframes 0-3 */				for ( i = 0; i < IPP_G723_NUM_SUBFRAME; i ++ )					for ( j = 0; j < 4; j ++ )						*pTemp1++ = (Ipp8u)((fixedCbPulseSign[i] >> j) & 1);			}			break;	}	/* Generate compressed bitstream from the uncompressed bitstream. 	   Pack eight bits at a time "octets" from the buffer iBitStream[]       into the compressed buffer pDstBitStream[]. 	*/	switch (frameType)	{		case 0:			iTemp1 = 1;			break;		case 1:			if ( bitRate == IPP_SPCHBR_6300 )				iTemp1 = _G723_STREAM_BYTES_63KBPS;			else				iTemp1 = _G723_STREAM_BYTES_53KBPS;			break;		case 2:			iTemp1 = 4;			break;	}	pTemp1 -= (iTemp1 << 3);	for ( i = 0; i < iTemp1; i ++ )	{		iTemp2 = 0;		for ( j = 0; j < 8; j ++ )			iTemp2 += ((Ipp16s)pTemp1[j] << j);		pDstBitStream[i] = (Ipp8u)iTemp2;		pTemp1 += 8;	}	switch (frameType)	{		case 0:			*pDstNumBitstreamBytes=1;			break;		case 1:			if (bitRate==IPP_SPCHBR_5300)				*pDstNumBitstreamBytes=IPP_G723_BITSTREAM_LEN_5300;			else				*pDstNumBitstreamBytes=IPP_G723_BITSTREAM_LEN_6300;			break;		case 2:			*pDstNumBitstreamBytes=4;			break;	}//	if (bitRate==IPP_SPCHBR_5300)//		*pDstNumBitstreamBytes=IPP_G723_BITSTREAM_LEN_5300;//	else//		*pDstNumBitstreamBytes=IPP_G723_BITSTREAM_LEN_6300;	/* Maintain frame type history */	*frameTypeHistory=frameType;	return(IPP_STATUS_OK);	}IppStatus	appsUnpackBitstream_G723_8u(Ipp8u *pSrcBitStream,										int *pDstNumBitstreamBytes,										Ipp32s *quantLsfIndex, 										Ipp16s *adaptCbLagAbs,										Ipp16s *adaptCbLagDiff,										Ipp16s *adaptCbGainIndex,										Ipp16s *fixedCbGainIndex,										Ipp16s *fixedCbDiracPulseFlag,										Ipp16s *fixedCbGridAlign,										Ipp32s *fixedCbPulsePos,										Ipp16s *fixedCbPulseSign,										Ipp16s *InterpolationGain,										Ipp16s *ConsecutiveFrameErasures,										Ipp16s prevDTXFrameType,										Ipp16s *frameType,										IppSpchBitRate *bitRate,										Ipp16s *InvalidFrame){	int		i,j;										/* general loop indices */											Ipp8u	iBitStream[_G723_STREAM_BYTES_63KBPS<<3];   /* bitstream "expansion" or "decompression" buffer 												           holds 1 stream bit in each 8-bit word */	Ipp16s	iFrameType;									/* frame type as indicated by VADFLAG_B0 and RATEFLAG_B0 bits */	Ipp16s	iTemp1,iTemp2;								/* Miscellaneous Ipp16s temp variables used throughout decoder */	Ipp32s	nTemp1;										/* Ipp32s temp variable used throughout decoder */	Ipp8u	*pTemp1;									/* Raw bitstream pointer */	/* Extract bitrate and frame type */	pTemp1 = iBitStream;	iTemp2 = (Ipp16s)pSrcBitStream[0];	for ( j = 0; j < 8; j ++ )	{		* pTemp1 ++ = (Ipp8u)((iTemp2 >> j) & 1);	}	iTemp1 = iBitStream[0] + (iBitStream[1] << 1);	/* NonTX */	if ( iTemp1 == 3 )	{		iFrameType = 0;	} 	/* SID */	else if ( iTemp1 == 2 )	{		iFrameType = 2;	} 	/* voice frame */	else if ( iTemp1 == 1 )	{		iFrameType = 1;		*bitRate = IPP_SPCHBR_5300;	} 	else	{		iFrameType = 1;		*bitRate = IPP_SPCHBR_6300;	}	/* Process externally flagged erasure frames */	if ( *InvalidFrame )

⌨️ 快捷键说明

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