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

📄 mulawencoder.cpp

📁 Symbian手机游戏源码 很经典值得有兴趣的研究分析 希望大家一起进步
💻 CPP
字号:
#include "mulawencoder.h"/* * Based on example code from http://hazelware.luggle.com/tutorials/mulawcompression.html */static const TInt KMuLawBias = 0x84;static const TInt KMuLawClip = 32635;static const TUint8 KMuLawCompressTable[] = {	 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,	 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,	 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,	 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,	 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,	 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,	 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,	 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,	 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};static TUint8 ToMuLaw(TInt16 aSample) {	TInt sign = (aSample >> 8) & 0x80;	if (sign)		aSample = (TInt16) -(aSample + 1); // the +1 is for handling the case when aSample == -32768	if (aSample > KMuLawClip)		aSample = KMuLawClip;	aSample += KMuLawBias;	TInt exponent = KMuLawCompressTable[(aSample >> 7) & 0xFF];	TInt mantissa = (aSample >> (exponent + 3)) & 0x0F;	TUint8 compressedByte = ~ (sign | (exponent << 4) | mantissa);	return compressedByte;}TInt CMuLawEncoder::Encode(const TDesC8& aBuffer, TUint8* aOutBuffer) {	const TInt16* ptr = reinterpret_cast<const TInt16*>(aBuffer.Ptr());	TInt len = aBuffer.Length()/2;	for (TInt i = 0; i < len; i++) {		*aOutBuffer = ToMuLaw(*ptr);		ptr++;		aOutBuffer++;	}	return len;}

⌨️ 快捷键说明

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