【问题标题】:speex and jspeex decodingspeex 和 jspeex 解码
【发布时间】:2013-01-24 20:36:09
【问题描述】:

Jspeex 有一个解码方法,如下所示:

 public static int decode(byte[] input, int offset, int length, byte[] output) throws StreamCorruptedException {

    SpeexDecoder decoder = new SpeexDecoder();
    decoder.init(0, 8000, 1, true, length);
    decoder.bits.read_from(input, offset, length);
    int o_offset = 0;
    while ( decoder.bits.getBufferSize() < length )
    {
        decoder.decodeToByteArray(output, o_offset);
        o_offset += 320;
    }

    return o_offset;
}

作为输入,我给出了一个长度不确定的字节数组,但方法只是正确地填充了我的输出缓冲区。换句话说,我给出了一堆彼此相邻的帧,但是解码器可以处理连续的帧。但是有些机器速度很慢,所以我决定将 speex 与 jni 包装器一起使用。同样,我们有一个方法如下所示:

public short[] decode(byte[] frame)
{
    return decode(slot, frame);
}

private native static short[] decode(int slot, byte[] frame);

以上 jni 包装的解码方法只接受单帧。所以我的问题是我们如何使用 jni 包装的 speex 对 jspeex 做完全相同的事情。

PS:我尝试将连续帧分成单独的帧,但连续帧的长度与 number_of_frames X length_of_a_frame 不匹配。

对不起,我的英语太棒了(?),在此先感谢。

【问题讨论】:

    标签: android decoding speex jspeex


    【解决方案1】:

    对于那些面临同样问题的人,您可以这样做: 你最好在 jni 里面做。

    for(int i=0;i<frames;i++) {
        if(speex_decode_int(dec_state, &dbits, output_buffer+i*dec_frame_size)!=0) {
            __android_log_print(ANDROID_LOG_ERROR, "Speex_jni", "Error in decoding");
            return (jint)0;
        }
    }
    

    您需要知道framestho 的号码。

    【讨论】:

      猜你喜欢
      • 2011-05-15
      • 2012-01-15
      • 2014-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      • 1970-01-01
      相关资源
      最近更新 更多