Android speex和jspeex解码
Jspeex有一种解码方法,如下所示:Android speex和jspeex解码,android,decoding,speex,jspeex,Android,Decoding,Speex,Jspeex,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_fro
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;
}
public short[] decode(byte[] frame)
{
return decode(slot, frame);
}
private native static short[] decode(int slot, byte[] frame);
上面的jni包装解码方法只接受单个帧。所以我的问题是,我们如何使用jni包装的speex对jspeex做完全相同的事情
PS:我试图将连续帧分割成单独的帧,但连续帧的长度与帧的数量X帧的长度不匹配
对不起,我的英语太棒了,提前谢谢。对于那些面临同样问题的人,以下是你的做法: 你最好在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;
}
}
你需要知道框架的数量