Re: Endian stuff was: Re: SPDIF encoded output on G5
Re: Endian stuff was: Re: SPDIF encoded output on G5
- Subject: Re: Endian stuff was: Re: SPDIF encoded output on G5
- From: Doug Wyatt <email@hidden>
- Date: Wed, 30 Nov 2005 17:32:39 -0800
Hi Urs,
On Nov 30, 2005, at 17:11, Urs Heckmann wrote:
Btw... sorry for hijacking... does anybody have a super quick way
for byte swapping an arbitrary number of longs/floats? Something
like industrial strength dsp code?
How would you implement this function on PPC and/or/vs. Intel:
inline void swapEndian( UInt32 &ICameFromOuterSpace )
{
// ?
}
I think I saw a fancy trick years ago using shifts and exclusive
or. But I can't remember.
I guess the slowest must be using arrays of chars... as these might
occupy a lot of registers... or not so?
On PPC with Altivec I'd use vec_perm.
On PPC without Altivec I'd use a loop with lwbrx or stwbrx to load or
store byte-swapped values from memory. There are some helpful inlines
for these instructions in <libkern/OSByteOrder.h> (look for the ppc-
specific implementation).
On Intel I'd briefly wish for vec_perm and settle for a series of
about 5 SSE instructions involving shuffles and a 16-bit byteswap
(using shift / shift / or).
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden