如何将 G.726 ADPCM 信号转换为 PCM 信号?

发布于 2024-08-26 05:41:33 字数 936 浏览 11 评论 0原文

我通常会在 SoX 或 Window 的内置音频库中查找这些内容,但似乎两者都没有 G.726 编解码器。

因此,我有一个字节序列,我知道它被编码为 G.726,尽管目前尚不知道比特率以及它是 mu-law 还是 A-law(实验将确定这些参数),并且我需要将它们解码为正常的 PCM 信号。

因此,我从 ITU-T(ITU-T 建议 G.191)下载了参考实现,但我对如何使用 G726_decode 函数有点困惑。根据文档 inp_bufout_buf 需要具有相同的长度 smpno 并且两个缓冲区都是 16 位缓冲区。在我看来,这似乎少了一步;否则,使用 G.726 无法完成压缩。根据 G.726 的维基百科页面,样本大小取决于比特率(从 2 到 5位)。我应该自己对样本进行解压吗?因此,如果我假设最大压缩(2 位样本),那么每个字节将产生 4 个样本。

例如:

char b = /* read the code from input */
short inp[4], output[4];
inp[0] = b & 0x0003;
inp[1] = b & 0x000C >> 2;
inp[2] = (b & 0x0030) >> 4;
inp[3] = (b & 0x00C0) >> 6;
G726_state state;
memset(&state, 0, sizeof(G726_state));
G726_decode(inp, output, 4, "u", 2, 1, &state);
/* ouput now contains 4 PCM samples */

或者我完全错过了一些东西?

I usually look to SoX or Window's built in audio libraries for this stuff, but it appears that neither have G.726 codecs.

So I have a sequence of bytes that I know are encoded as G.726 although the bit-rate and whether it is mu-law or A-law is not known at this time (experimentation will determine those parameters), and I need to decode them into a normal PCM signal.

So I downloaded the reference implementation from the ITU-T (ITU-T Recommendation G.191) but I'm kind of confused on how to use the G726_decode function. According to the documentation inp_buf and out_buf need to have the same length smpno and both buffers are 16-bit buffers. This seems to me like a step is missing; otherwise no compression is accomplished by using G.726. According to the Wikipedia page on G.726 sample size depends on bit rate (from 2 to 5 bits). Am I supposed to do the decompression into samples myself? So if I assume maximum compression (2 bit samples) then each byte will produce 4 samples.

Example:

char b = /* read the code from input */
short inp[4], output[4];
inp[0] = b & 0x0003;
inp[1] = b & 0x000C >> 2;
inp[2] = (b & 0x0030) >> 4;
inp[3] = (b & 0x00C0) >> 6;
G726_state state;
memset(&state, 0, sizeof(G726_state));
G726_decode(inp, output, 4, "u", 2, 1, &state);
/* ouput now contains 4 PCM samples */

Or am I missing something completely?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

×眷恋的温暖 2024-09-02 05:41:33

看起来 ffmpeg 实际上无法做到这一点,因为我认为它肯定能够......但是,当我在谷歌搜索时,我确实发现了这个 发布到 ffmpeg 邮件列表,它提供了解决方案。

基本上,有一个名为 g72x++ 的单独程序,它似乎能够解码为您将音频转换为原始 PCM。

Looks like ffmpeg actually isn't able to do this, as I thought it surely would be able to... however, while I was googling I did find this post to the ffmpeg mailing list which offers a solution.

Basically, there is a separate program called g72x++ which seems to be able to decode the audio to raw PCM for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文