用于音频对讲: 解g711u数据流和压缩pcm的数据流的方法
来源:互联网 发布:改良圈算法 编辑:程序博客网 时间:2024/06/05 09:21
int UlawCodec_decode(int16_t *samples, int count, void *payload, int length)
{
int8_t *ulaws = (int8_t *)payload;
if (length > count) {
length = count;
}
for (int i = 0; i < length; ++i) {
int ulaw = ~ulaws[i];
int exponent = (ulaw >> 4) & 0x07;
int mantissa = ulaw & 0x0F;
int sample = (((mantissa << 3) + 132) << exponent) - 132;
samples[i] = (ulaw < 0 ? -sample : sample);
}
return length;
}
//pcm2g177u
//const int8_t gExponents[128] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
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,
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,
};
int UlawCodec_encode(void *out, int16_t *in, int mSampleCount)
{
int8_t *ulaws = (int8_t *)out;
for (int i = 0; i < mSampleCount; ++i) {
int sample = in[i];
int sign = (sample >> 8) & 0x80;
if (sample < 0) {
sample = -sample;
}
sample += 132;
if (sample > 32767) {
sample = 32767;
}
int exponent = gExponents[sample >> 8];
int mantissa = (sample >> (exponent + 3)) & 0x0F;
ulaws[i] = ~(sign | (exponent << 4) | mantissa);
}
return mSampleCount;
}
1 0
- 用于音频对讲: 解g711u数据流和压缩pcm的数据流的方法
- c#中关于压缩数据流和解压数据流的实现
- 获取返回的压缩数据流
- chapter19_20_TCP的交互数据流和块数据流
- TCP的交互数据流和成块数据流
- TCP的交互数据流和成块数据流
- hadoop 对数据流的压缩和解压缩
- AVCodecParser用于解析输入的数据流并把它分成一帧一帧的压缩编码数据。
- AVCodecParser用于解析输入的数据流并把它分成一帧一帧的压缩编码数据。
- AVCodecParser用于解析输入的数据流并把它分成一帧一帧的压缩编码数据。
- C++ pcm音频裸流的压缩和解码
- 面向数据流的设计方法
- 面向数据流的设计方法
- 面向数据流的设计方法
- 数据流的压缩、编码及传递困扰
- 【网络协议】TCP的交互数据流和成块数据流
- 【网络协议】TCP的交互数据流和成块数据流
- kinect深度数据流和彩色数据流的捕捉
- Qt利用QSplashScreen类自定义初始化启动界面
- CentOS+Nginx一步一步开始配置负载均衡
- PHP : mysqli【面向对象】操作数据库【连接、增、删、改、查】
- 如何使用Java List等集合类的removeAll方法
- Ajax, 选择GET还是POST?(转)
- 用于音频对讲: 解g711u数据流和压缩pcm的数据流的方法
- Java实现二分查找--非递归
- Hough变换检测圆
- iOS中的initialize与load两个类方法简单理解
- asp.net 51个常用技巧总结
- cvc-complex-type.2.4.c: The matching wildcard is strict
- 套路、逻辑与思辨
- ios富文本功能/文字特性设置
- 2016国庆节快乐