解码G711(PCM u-law) [英] Decode G711(PCM u-law)

查看:391
本文介绍了解码G711(PCM u-law)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请耐心听,因为我对音频编解码器的了解有限. 我有一个来自IPCAM的音频源(通过htto//... CGI接口). 我正在尝试编写一些客户端程序来在Windows,MAC和Android手机上播放此音频源.音频以G711(PCM ulaw)编码.

Please bear with me as my understanding of audio codec is limited. I have this audio source from a IPCAM (through a htto//... CGI interface). I am trying to write several client programs to play this audio source on Windows, MAC, as well as Android phone. The audio is encoded in G711 (PCM ulaw).

在将PCM音频数据传递到音频引擎进行播放之前,是否需要将PCM音频数据解码为原始音频数据?如果是这样,是否有一些有关如何解码的示例代码? 我感到困惑,因为我以某种方式认为PCM已经是RAW.例如,我可以直接将其直接馈送到Android上的音频引擎吗?

Do I need to decode the PCM audio data to a raw audio data before I could pass it to the audio engine to play? If so, is there some sample code on how to decode it? I am confused as somehow I believe PCM is already RAW. Could I just feed it directly to the audio engine on Android for example?

非常感谢

推荐答案

这取决于您用来播放声音的API,但是大多数需要线性PCM并且您具有µ-law PCM,因此除非您的API支持µ-law回放时,您需要将µ-law采样值转换为线性值.

It depends on what API you are using to play sound, but most require linear PCM and you have µ-law PCM, so unless your API supports µ-law playback you will need to convert the µ-law sample values to linear.

对于G.711,压缩后的µ-law样本为8位,它们将转换为14位线性值,您将以每个样本2个字节的形式将其存储在缓冲区中. G.711 Wikipedia页面.

With G.711 the compressed µ-law samples are 8 bits and these will be converted to 14 bit linear values which you will store in a buffer as 2 bytes per sample. There is a brief description of the µ-law encoding on the G.711 Wikipedia page.

这篇关于解码G711(PCM u-law)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆