[vorbis] developing with libvorbis
Ed Sweetman
ed.sweetman at WMICH.EDU
Wed Mar 26 17:33:04 PST 2003
Sune Foldager wrote:
> On thursday, march 27, 2003, at 01:35 (Europe/Copenhagen time), Ed
> Sweetman wrote:
>
>> In the example decoder it writes data in varying lengths to stdout, is
>> it possible to alter the decoder to write the same length data to
>> stdout every time? Rather, how would you alter the decoder to do
>> that. It seems to be writing everything from 512 to 4096 bytes each
>> time and i cant really see why this is and how to change it.
>
>
> This is because the decoder doesn't decode farther than the current
> frame. Make a small loop, repeatedly calling the decode function until
> you get the amount you need. I believe it says something about this in
> the libvorbisfile documentation. Something like this:
>
> int left = 4096;
> while(left > 0)
> {
> int data_read = vorbis_read(..., left); // Can't remember the name
> of the decode function.
> // Do something with data, e.g. buffer it.
> left -= data_read;
> }
> // Write buffer to stdout or similar. Unless there was an EOF, it should
> be size 4096.
>
> In the above code, special concern needs to be taken with regard to EOF.
>
what about something like this
right where it says fwrite in the example decoder
if(left > 0){
memcpy(tbuffer+(4096-left),convbuffer,bout*2*vi.channels);
left -= bout*2*vi.channels;
} else {
do my write function with the knowledge that i'm writing 4096 bytes
left = 4096;
}
can i really be sure that it wont try writing 1024 bytes one time and
then 4096 the next? and other combinations that overrun 4096?
<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 'vorbis-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 Vorbis
mailing list