Re: [AD] Speed wav loader way up

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 14 April 2010 10:55, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> On Tue, Apr 13, 2010 at 7:15 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
>> I've had this fix in my private branch for a while but I forgot about it.
>> Basically, I'm not sure it's a 100% proper approach, but it speeds up
>> wav loading about 20x at least. It's a one liner as is (though you could
>> remove the extra code following this line if it's found that this solution
>> will work):
>>
>> -    if (wavfile->bits == 8) {
>> +   if (1) {
>>
> I probably wrote that code... don't remember how much I copy / pasted from A4.
>
> Anyway, the distinction is probably meant for universal support for
> big/little endian. If it is necessary, then an #ifdef could be used to
> optimize for x86.

That looks right.  The overhead is from the individual al_fgetc calls,
which have to go through the file stream vtable.

The optimisation would be to read a whole buffer of 16-bit sample values into
the buffer with a single al_fread call.  Then for #ifdef ALLEGRO_BIGENDIAN, make
a pass over the buffer to swap the endianness.  PCM data in wave files is little
endian, unless the identifier is "RIFX", which we apparently don't support.[1]

Peter

[1] https://ccrma.stanford.edu/courses/422/projects/WaveFormat/




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/