Hello there, I thought I would contribute to this wonderful project but noting a simple but problematic bug in speex_bits_read_whole_bytes(). SITUATION: I have a large stream of frames with NO breaks or length indicators inbetween each frame. For this reason, I call speex_bits_read_whole_bytes() and fill it to MAXIMUM in a loop while calling speex_decode() until there are no more bytes to read. SYMPTOM: You can only go up to MAX_BYTES_PER_FRAME-1 due an incorrect calculation in the function. LINES THAT ARE THE PROBLEM: ((bits->nbBits>>3)+len+1 should read ((bits->nbBits+7)>>3)+len otherwise if nbBits is 0 or a full byte, the buffer will never get to MAX_BYTES_PER_FRAME. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Jean-Marc Valin
2004-Aug-06 15:01 UTC
[speex-dev] bug found in speex_bits_read_whole_bytes
OK, I fixed it but: 1) you shouldn't be using the MAX_BYTES_PER_FRAME constant (just moved it to the .c where it belongs) 2) if you read more than MAX_BYTES_PER_FRAME the buffer will resize automatically, so there's no problem. Just use the size you want. Jean-Marc Le lun 25/08/2003 à 02:27, Thomas S a écrit :> Hello there, > I thought I would contribute to this wonderful project > but noting a simple but problematic bug in > speex_bits_read_whole_bytes(). > > SITUATION: > I have a large stream of frames with NO breaks or > length indicators inbetween each frame. For this > reason, I call speex_bits_read_whole_bytes() and fill > it to MAXIMUM in a loop while calling speex_decode() > until there are no more bytes to read. > > SYMPTOM: > You can only go up to MAX_BYTES_PER_FRAME-1 due an > incorrect calculation in the function. > > LINES THAT ARE THE PROBLEM: > ((bits->nbBits>>3)+len+1 > should read > ((bits->nbBits+7)>>3)+len > otherwise if nbBits is 0 or a full byte, the buffer > will never get to MAX_BYTES_PER_FRAME. > > __________________________________ > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software > http://sitebuilder.yahoo.com > --- >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@xiph.org' > containing only the word 'unsubscribe' in the body. No subject is needed. > Unsubscribe messages sent to the list will be ignored/filtered.-- Jean-Marc Valin, M.Sc.A., ing. jr. LABORIUS (http://www.gel.usherb.ca/laborius) Université de Sherbrooke, Québec, Canada --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
> 1) you shouldn't be using the MAX_BYTES_PER_FRAME > constant (just moved > it to the .c where it belongs)How else do I know how many bytes to add to the buffer if I have many frames without breaks inbetween them? (no breaks because it wastes space and my code doesn't really need to know how many bytes in each frame). Unless there is some other way to know the max_encoded_bytes_per_frame or otherwise keep the bit buffer full enough for a complete frame at all times, I think MAX_BYTES_PER_FRAME should be kept public just like getting the decoded frame size is needed at times. Thanks, Thomas __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.