AW: [speex-dev] SPEEX_SET_USER_HANDLER once again

Norman Biehl n.biehl at gmx.de
Fri Nov 7 10:37:10 PST 2003



Jean-Marc wrote:

>I think what happened is that you did not write the "message" length.
>With user-callbacks, you also need to say how large the message. The
>size is in bytes and encoded in 4 bits.

I wonder what is correct. Inside speex the documentation was written
that the size in byte is encoded within 5 bit.
 
I changed the code in both ways, but it doesn't work anytime. It's the
same problem. See below.

>Besides, you're probably the first one to use user-callbacks. 

Oh, I feel honoured. :-)

Why does it contain this feature if nobody uses it? I think it's a good
and very flexible feature (if it works :-)).

>BTW, why
>didn't you want to use Ogg. It's much simpler to use and overhead can
be
>made minimal anyway.

At first there is no need for ogg, the programm is only for encoding
voice in a test environment. 
And if the user in-band callback mechanism works it is more then enough.

<p><p>void CSpeexEncoderThread::Decode(char * pcData, DWORD dwLength){ 
          
        ... 
 
        speex_encode(st, s, &bits); // encode 
        if (syncmsg == TRUE && synccount < 256){ // is there a sync
message? 
 
              syncstruct[synccount].sync_value = syncvalue; //fill the sync
structure 
 
            ... 
                //custom in-band messages  		     
                speex_bits_pack(&bits, 13, 5);
                
                // write the length of the message
                speex_bits_pack(&bits, 1, 4);

            // write the array index of the sync structure into the
stream (max. 256 sync points) 
            speex_bits_pack(&bits, synccount, 8); 
 
            synccount++ 
        } 

        nbBytes = speex_bits_write(&bits, cbits, MAX_FRAME_BYTES); 
         
        ... 
 
        // write the encoded data into the end buffer 
 
        ... 
 
        speex_bits_reset(&bits); 
 
        ... 
 } 

int CSpeexDecoderThread::SpeexUserCallback(SpeexBits *bits, void *state,
void *data){

        int length	= speex_bits_unpack_unsigned(bits, 4);
        int inedx 	= speex_bits_unpack_unsigned(bits, length * 8);

<p>      SendNotifyMessage(l_sdthread->m_hWnd, USER_PLAYBACK_MESSAGE,
SYNC_DATA, LPARAM(index));
        return 0;
}

<p><p><p><p><p><p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Speex-dev mailing list