a_tuzi 2013-07-15 08:06 采纳率: 0%
浏览 1296

android里面怎么把speex解码成pcm啊?

android里面怎么把speex解码成pcm啊?
android里面怎么把speex解码成pcm啊?
android里面怎么把speex解码成pcm啊?

  • 写回答

1条回答 默认 最新

  • ChatGPTᴼᴾᴱᴺᴬᴵ 2023-01-05 20:23
    关注

    可以使用Speex库中提供的解码器来将Speex编码的音频文件解码成PCM格式。


    具体来说,你需要使用Speex库中的speex_decoder_init函数来初始化一个解码器,然后使用speex_decode函数来对Speex编码的音频进行解码。


    下面是一个示例代码,它展示了如何将Speex编码的音频解码成PCM格式:

    #include <speex/speex.h>
    #include <stdio.h>
    
    int main(int argc, char **argv) {
      char *inFile;
      FILE *fin;
      short out[FRAME_SIZE];
      void *state;
      SpeexBits bits;
      int i, tmp;
    
      /* Open the file and check if it's a Speex file */
      inFile = argv[1];
      fin = fopen(inFile, "rb");
      if (!fin) {
        fprintf(stderr, "Cannot open %s\n", inFile);
        exit(1);
      }
      speex_bits_init(&bits);
    
      /* Initialize the decoder */
      state = speex_decoder_init(&speex_uwb_mode);
    
      /* Set decoder options */
      tmp=1;
      speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
    
      while (1) {
        /* Read a frame */
        if (!speex_bits_read_from(&bits, fin, SPEEX_FRAME_SIZE))
          break;
    
        /* Decode the data */
        speex_decode(state, &bits, out);
    
        /* Write the decoded audio to file */
        fwrite(out, sizeof(short), FRAME_SIZE, stdout);
      }
    
      /* Destroy the decoder state */
      speex_decoder_destroy(state);
      speex_bits_destroy(&bits);
      fclose(fin);
    
      return 0;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站