能跑,没测试。心情问题……
private final static short SHORT_MAX = 0x7FFF;
public static byte[] convertPcmToG711(byte[] pcmBuffer, int length, byte[] g711Buffer)
{
length = length/2;
if (pcmBuffer == null)
{
pcmBuffer = new byte[length];
}
for (int i=0; i> 8;
if (sign != 0)
{
pcm = (short)-pcm;
}
if (pcm > SHORT_MAX)
{
pcm = SHORT_MAX;
}
int exponent = 7;
int expMask;
//有的使用数组来代替这个步骤。
for (expMask = 0x4000; (pcm & expMask) == 0 && exponent>0; exponent--, expMask >>= 1)
{
//
}
int mantissa = (pcm >> ((exponent == 0) ? 4 : (exponent + 3))) & 0x0F;
byte alaw = (byte)(sign | exponent
关注
打赏
热门博文
- 历史最高名次:17
- 日常收集的妙语
- git更新:Your local changes to the following files would be overwritten by merge
- Github通过PR提交代码到开源库
- Github参与OpenJDK8的开发指南
- FreeType可以指定斜体值了!祝贺修改代码整合进入FreeType
- JDK/FreeType中关于斜的英文有哪些
- WINDOWS编译ffmpeg:LINK : fatal error LNK1104: 无法打开文件“LIBCMT.lib”
- 全网首发:编译ffmpeg: error: ‘VFW_E_NOT_FOUND‘ undeclared ; did you mean ‘NTE_NOT_FOUND‘?
- WINDOWS+VS2012+msys2编译ffmpeg成功,DLL不能用