[Speex-dev] Speex issue

Philip Bliss pbliss at peralex.com
Fri Jul 11 07:55:25 PDT 2008


Hey there

I had implemented Speex encoding nicely in an application I was working 
on when I realized that I needed to change the API. I changed it, and 
the change somehow broke the speex encoding section of the code. The 
program writes SPX headers that other programs can read, but does not 
generate the rest of the file correctly. I have been through the guide 
"programming with speex", and I've been through the reference speexenc 
line by line, but I just can't figure out what's wrong with my code. I'm 
hoping that there's some glaring error that you guys will shout at me 
for missing. This method is called when enough data has accumulated in 
inputFrame, after the members have been initialized and the headers have 
been written:

    oggPacketCount++;
    speex_bits_reset(&speexBits);
    speex_encode_int(encoderState, inputFrame, &speexBits);
    int packetBytes = speex_bits_write(&speexBits, packetBuffer, 
PACKET_BUFFER_SIZE);

    oggPacket.packet = (unsigned char*)packetBuffer;
    oggPacket.bytes = packetBytes;
    oggPacket.b_o_s = 0; //this is not the beginning of the stream
    oggPacket.e_o_s = (lastFrame) ? 1 : 0;
    oggPacket.granulepos = (1 + oggPacketCount) * inputFrameSize - 
lookahead;
    oggPacket.packetno = 2 + oggPacketCount;
    ogg_stream_packetin(&oggStream, &oggPacket);

    while (((lastFrame) ? ogg_stream_flush(&oggStream, &oggPage) : 
ogg_stream_pageout(&oggStream,&oggPage)) != 0)
    {
        file.write((char*)oggPage.header,oggPage.header_len);
        file.write((char*)oggPage.body, oggPage.body_len);
    }

I know this is a long shot, but any advice would be appreciated--I'm 
desperate!

Thank you,
Philip Bliss

Disclaimer: http://www.peralex.com/disclaimer.html




More information about the Speex-dev mailing list