Hi, ??Forgive my poor English, I'm trying to implement a net phone using vorbis codec, which need realtime encode and decode the stream. The problem is, I use vorbis_analysis_buffer() and vorbis_analysis_wrote() push the PCM data in, then use vorbis_analysis_blockout(&vd, &vb) to output a block, it can't output all the data. It seems that some data which length is constant, must be in the vorbis_dsp_state, can not be output. When Decode, there's similar problem. These lead time lapse. I have tested, 22050, 1 channel. First, vorbis_analysis_wrote(&vd, 2048), vorbis_analysis_blockout(&vd, &vb), no block out. After, every time vorbis_analysis_wrote(&vd, 1024), vorbis_analysis_blockout(&vd, &vb), one or two block out, but I guess it's content is which I have pushed in previously. Is there a solution to encode and decode realtime, no leavings? Like vorbis_bitrate_flushpacket(), flush a block? Regards ??????????????
On Tue, Sep 18, 2007 at 11:55:32AM +0800, yut_1985@foxmail.com wrote:> ??Forgive my poor English, I'm trying to implement a net phone using vorbis codec, which need realtime encode and decode the stream.Vorbis isn't appropriate for interactive chat. The latency is too high. You might look at speex instead if you are doing voice.> The problem is, I use vorbis_analysis_buffer() and vorbis_analysis_wrote() push the PCM data in, then use vorbis_analysis_blockout(&vd, &vb) to output a block, it can't output all the data. It seems that some data which length is constant, must be in the vorbis_dsp_state, can not be output. When Decode, there's similar problem. These lead time lapse.The encoder requires a working buffer of several blocks to choose optimum coding, and will create compressed blocks of two different sizes based on the encoding mode and nature of the audio. In general, you must repeatedly call call each output stage repeatedly until it asks for more data. When all stages are asking for more data, call vorbis_analysis_wrote to submit more. This way it can buffer the data it needs, and you are certain to write out what is available as soon as possible. See examples/encoder_example.c in the source package for more detail. Hope that helps, -r