Decode G711(PCM u-law)

匆匆过客 提交于 2019-12-02 03:57:34

问题


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).

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?

thanks much in advance


回答1:


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.

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.




回答2:


You may find this useful:

u-Law companding algorithm in C



来源:https://stackoverflow.com/questions/3251782/decode-g711pcm-u-law

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!