Hi all, First of all, thanks to Speex developper for the all the job. I am trying to implement my own Speex DirectShow fitlers for VoIP following the documentation and sample code's. I am facing audio glitches when encoding - decoding PCM data. The encoder and decoder procedures are copied below. What about the lookahead size ? how shouw we apply it in encoding stage ? thanks in advance bool SpeexEncoder::EncodeData(char * inBuffer, int inSize, char * outBuffer, int outMAXSize, int* outSize) { if(!m_Initialized) return false; // Copy data into the local buffer memcpy(m_pBuffer + m_BufferSize, inBuffer, inSize); m_BufferSize += inSize; // check if we have enougth data for the encoder, if(m_BufferSize < m_FrameSizeInBytes ) return false; // start processing short* input = (short*)m_pBuffer; char* output = outBuffer; *outSize = 0; int tmpBufferSize = m_BufferSize; while(tmpBufferSize >= m_FrameSizeInBytes + m_SpeexLookAheadInBytes) { speex_bits_reset(&m_SpeexBits); if(m_Channels == 2) speex_encode_stereo_int(input, m_FrameSizeInSamples, &m_SpeexBits); if (m_SpeexPreprocessState != NULL) speex_preprocess(m_SpeexPreprocessState, input, NULL); speex_encode_int(m_SpeexState, input, &m_SpeexBits); int bytes = speex_bits_write(&m_SpeexBits, output, outMAXSize); input += m_FrameSizeInBytes; output += bytes; *outSize += bytes; tmpBufferSize -= m_FrameSizeInBytes; } // if we consumed data from the buffer, it needs to be rearanged in order to keep only .... return true; } bool SpeexDecoder::DecodeData( char * inBuffer, int inSize, char ** outBuffer, int outMAXSize, int* outSize) { if(!m_Initialized) return false; int remains = inSize; char * input = inBuffer; short * output = (short*) *outBuffer; int size = 0; while(remains > 0) { speex_bits_read_from(&m_SpeexBits, input, remains); int locRet = speex_decode_int(m_SpeexState, &m_SpeexBits, output); if (locRet == -1 || locRet == -2) return false; if ((remains = (speex_bits_remaining(&m_SpeexBits))/8) < 0) //Corrupted return false; if (m_Channels == 2) speex_decode_stereo_int((short *)output, m_FrameSizeInSamples, &m_StereoState); size += m_FrameSizeInBytes; output += m_FrameSizeInBytes; input = inBuffer + inSize - remains; } *outSize = size; return true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20071114/19e18e94/attachment.htm