[vorbis-dev] use of 'long' in vorbis structures

David Etherton etherton at rockstarsandiego.com
Thu May 22 07:57:31 PDT 2003


Attached is a patch to codebook.c to add some explicit casts to ogg_int32_t.
On some platforms, multiplication and division of longs is slower than ints;
from looking at the code, it's expecting longs to be at least 32 bits wide,
so ogg_int32_t is a safe choice.

In a few places, the code was doing int quantvals = long * long, so I cast
the operands to int instead of ogg_int32_t for clarity.

These minor changes eliminated __divdi3 and __muldi3 from my profiles
entirely (and should help on other 64-bit machines that still only have
32-bit multipliers and dividers).

I still think the codebook structures should be changed to ogg_int32_t or
whatever type is more suitable because I presume they're wasting memory
bandwidth on platforms where sizeof(long) > sizeof(int).  I'll look into
doing this myself next.

-Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: codebook-long-patch.gz
Type: application/x-gzip
Size: 934 bytes
Desc: codebook-long-patch.gz
Url : http://lists.xiph.org/pipermail/vorbis-dev/attachments/20030522/a610f0d4/codebook-long-patch.bin


More information about the Vorbis-dev mailing list