[vorbis] developing with libvorbis
Ed Sweetman
ed.sweetman at wmich.edu
Wed Mar 26 17:55:27 PST 2003
Sune Foldager wrote:
> On torsdag, mar 27, 2003, at 02:33 Europe/Copenhagen, Ed Sweetman wrote:
>
>> 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;
>> }
>
>
> Yes, if you remembered to pass the 'left' variable to the decode
> function correctly. See below.
>
>> 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?
>
>
> Well, without having looked at the example in a bit, I am sure there is
> no problem. The reason being that you specify a maximum size for the
> decode function. It will NOT decode more than that. It MAY decode less,
> and it will do so if the frame stops before the buffer is full. So by
> filling the buffer in a loop like I suggested, __and passing the 'left'
> parameter to the decode function__ (instead of just 4096), it should
> work fine.
>
except i get decodes that can go like this
2304
4096
Now there is no easy way to handle something like that. Suppose the
smallest data i can write to the soundcard is 2048bytes. Vorbis is
giving me stuff that's like 512, 1024 ...and sometimes 2304 and 4096.
If i dont use all of what it decodes because say it gives me 2304 and
then 4096, how can i tell it that i didn't read all it's packets and
that it should start where i left off on it's next cycle of decoding? I
dont think it's a matter of saying to only seek X amount in the file
since we're talking about decoded data and there's no easy way to figure
out where exactly in the file I left off at decoding. I dont think it's
possible to leave an offset from a decode.
--- >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