[plain text]
#include <libkern/OSTypes.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOLib.h>
class IOMemoryDescriptor;
#include <IOKit/audio/IOAudioTypes.h>
#include "AppleUSBAudioClip.h"
#include "AppleUSBAudioCommon.h"
extern "C" {
typedef float Float32;
typedef double Float64;
#define FLOATLIB FALSE
#if FLOATLIB
void CoeffsFilterOrder2 (Float32 *Coeff, Float32 CutOffFreq, Float32 AttAtCutOffFreq , Float64 SamplingRate);
#else
Boolean CoeffsFilterOrder2Table (Float32 *Coeff, UInt32 samplingRate);
#endif
void MonoFilter (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 samplingRate);
void StereoFilter (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 samplingRate, PreviousValues *theValue);
void StereoFilter4thOrder (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 samplingRate, PreviousValues *section1State, PreviousValues *section2State);
void StereoFilter4thOrderPhaseComp (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 samplingRate, PreviousValues *section1State, PreviousValues *section2State, PreviousValues *phaseCompState);
UInt32 CalculateOffset (UInt64 nanoseconds, UInt32 sampleRate) {
return (UInt32)(((double)sampleRate / 1000000000.0) * nanoseconds);
}
inline static SInt16 Endian16_Swap(SInt16 inValue)
{
return (((((UInt16)inValue)<<8) & 0xFF00) | ((((UInt16)inValue)>>8) & 0x00FF));
}
inline static SInt32 Endian32_Swap(SInt32 inValue)
{
return (((((UInt32)inValue)<<24) & 0xFF000000) | ((((UInt32)inValue)<< 8) & 0x00FF0000) | ((((UInt32)inValue)>> 8) & 0x0000FF00) | ((((UInt32)inValue)>>24) & 0x000000FF));
}
#if defined(__ppc__)
void Int8ToFloat32( SInt8 *src, float *dest, unsigned int count );
void NativeInt16ToFloat32( signed short *src, float *dest, unsigned int count, int bitDepth );
void SwapInt16ToFloat32( signed short *src, float *dest, unsigned int count, int bitDepth );
void NativeInt24ToFloat32( long *src, float *dest, unsigned int count, int bitDepth );
void SwapInt24ToFloat32( long *src, float *dest, unsigned int count, int bitDepth );
void NativeInt32ToFloat32( long *src, float *dest, unsigned int count, int bitDepth );
void SwapInt32ToFloat32( long *src, float *dest, unsigned int count, int bitDepth );
void Float32ToInt8( float *src, SInt8 *dst, unsigned int count );
void Float32ToNativeInt16( float *src, signed short *dst, unsigned int count );
void Float32ToSwapInt16( float *src, signed short *dst, unsigned int count );
void Float32ToNativeInt24( float *src, signed long *dst, unsigned int count );
void Float32ToSwapInt24( float *src, signed long *dst, unsigned int count );
void Float32ToNativeInt32( float *src, signed long *dst, unsigned int count );
void Float32ToSwapInt32( float *src, signed long *dst, unsigned int count );
static inline SInt16 SInt16BigToNativeEndian(SInt16 inValue) { return inValue; }
static inline SInt16 SInt16NativeToBigEndian(SInt16 inValue) { return inValue; }
static inline SInt16 SInt16LittleToNativeEndian(SInt16 inValue) { return Endian16_Swap(inValue); }
static inline SInt16 SInt16NativeToLittleEndian(SInt16 inValue) { return Endian16_Swap(inValue); }
static inline SInt32 SInt32BigToNativeEndian(SInt32 inValue) { return inValue; }
static inline SInt32 SInt32NativeToBigEndian(SInt32 inValue) { return inValue; }
static inline SInt32 SInt32LittleToNativeEndian(SInt32 inValue) { return Endian32_Swap(inValue); }
static inline SInt32 SInt32NativeToLittleEndian(SInt32 inValue) { return Endian32_Swap(inValue); }
#elif defined(__i386__)
static inline SInt16 SInt16BigToNativeEndian(SInt16 inValue) { return Endian16_Swap(inValue); }
static inline SInt16 SInt16NativeToBigEndian(SInt16 inValue) { return Endian16_Swap(inValue); }
static inline SInt16 SInt16LittleToNativeEndian(SInt16 inValue) { return inValue; }
static inline SInt16 SInt16NativeToLittleEndian(SInt16 inValue) { return inValue; }
static inline SInt32 SInt32BigToNativeEndian(SInt32 inValue) { return Endian32_Swap(inValue); }
static inline SInt32 SInt32NativeToBigEndian(SInt32 inValue) { return Endian32_Swap(inValue); }
static inline SInt32 SInt32LittleToNativeEndian(SInt32 inValue) { return inValue; }
static inline SInt32 SInt32NativeToLittleEndian(SInt32 inValue) { return inValue; }
#endif
#define kMaxClipSInt8 0.9921875
#define kFloat32ToSInt8 ((Float32)0x80)
#define kMaxClipSInt16 0.9999694824219
#define kFloat32ToSInt16 ((Float32)0x8000)
#define kMaxClipSInt24 0.9999998807907
#define kMaxClipSInt32 0.9999999995343
#define kFloat32ToSInt32 ((Float64)0x80000000)
inline static Float32 ClipFloat32ForSInt8(Float32 inSample)
{
if(inSample > kMaxClipSInt8) return kMaxClipSInt8;
if(inSample < -1.0) return -1.0;
return inSample;
}
inline static Float32 ClipFloat32ForSInt16(Float32 inSample)
{
if(inSample > kMaxClipSInt16) return kMaxClipSInt16;
if(inSample < -1.0) return -1.0;
return inSample;
}
inline static Float32 ClipFloat32ForSInt24(Float32 inSample)
{
if(inSample > kMaxClipSInt24) return kMaxClipSInt24;
if(inSample < -1.0) return -1.0;
return inSample;
}
inline static Float32 ClipFloat32ForSInt32(Float32 inSample)
{
if(inSample > kMaxClipSInt32) return kMaxClipSInt32;
if(inSample < -1.0) return -1.0;
return inSample;
}
#if defined(__i386__)
static void ClipFloat32ToSInt8_4(const Float32* inInputBuffer, SInt8* outOutputBuffer, UInt32 inNumberSamples)
{
register UInt32 theLeftOvers = inNumberSamples % 4;
while(inNumberSamples > theLeftOvers)
{
register Float32 theFloat32Value1 = *(inInputBuffer + 0);
register Float32 theFloat32Value2 = *(inInputBuffer + 1);
register Float32 theFloat32Value3 = *(inInputBuffer + 2);
register Float32 theFloat32Value4 = *(inInputBuffer + 3);
inInputBuffer += 4;
theFloat32Value1 = ClipFloat32ForSInt8(theFloat32Value1);
theFloat32Value2 = ClipFloat32ForSInt8(theFloat32Value2);
theFloat32Value3 = ClipFloat32ForSInt8(theFloat32Value3);
theFloat32Value4 = ClipFloat32ForSInt8(theFloat32Value4);
*(outOutputBuffer + 0) = (SInt8)(theFloat32Value1 * kFloat32ToSInt8);
*(outOutputBuffer + 1) = (SInt8)(theFloat32Value2 * kFloat32ToSInt8);
*(outOutputBuffer + 2) = (SInt8)(theFloat32Value3 * kFloat32ToSInt8);
*(outOutputBuffer + 3) = (SInt8)(theFloat32Value4 * kFloat32ToSInt8);
outOutputBuffer += 4;
inNumberSamples -= 4;
}
while(inNumberSamples > 0)
{
register Float32 theFloat32Value = *inInputBuffer;
++inInputBuffer;
theFloat32Value = ClipFloat32ForSInt8(theFloat32Value);
*outOutputBuffer = (SInt8)(theFloat32Value * kFloat32ToSInt8);
++outOutputBuffer;
--inNumberSamples;
}
}
static void ClipFloat32ToSInt16LE_4(const Float32* inInputBuffer, SInt16* outOutputBuffer, UInt32 inNumberSamples)
{
register UInt32 theLeftOvers = inNumberSamples % 4;
while(inNumberSamples > theLeftOvers)
{
register Float32 theFloat32Value1 = *(inInputBuffer + 0);
register Float32 theFloat32Value2 = *(inInputBuffer + 1);
register Float32 theFloat32Value3 = *(inInputBuffer + 2);
register Float32 theFloat32Value4 = *(inInputBuffer + 3);
inInputBuffer += 4;
theFloat32Value1 = ClipFloat32ForSInt16(theFloat32Value1);
theFloat32Value2 = ClipFloat32ForSInt16(theFloat32Value2);
theFloat32Value3 = ClipFloat32ForSInt16(theFloat32Value3);
theFloat32Value4 = ClipFloat32ForSInt16(theFloat32Value4);
*(outOutputBuffer + 0) = SInt16NativeToLittleEndian((SInt16)(theFloat32Value1 * kFloat32ToSInt16));
*(outOutputBuffer + 1) = SInt16NativeToLittleEndian((SInt16)(theFloat32Value2 * kFloat32ToSInt16));
*(outOutputBuffer + 2) = SInt16NativeToLittleEndian((SInt16)(theFloat32Value3 * kFloat32ToSInt16));
*(outOutputBuffer + 3) = SInt16NativeToLittleEndian((SInt16)(theFloat32Value4 * kFloat32ToSInt16));
outOutputBuffer += 4;
inNumberSamples -= 4;
}
while(inNumberSamples > 0)
{
register Float32 theFloat32Value = *inInputBuffer;
++inInputBuffer;
theFloat32Value = ClipFloat32ForSInt16(theFloat32Value);
*outOutputBuffer = SInt16NativeToLittleEndian((SInt16)(theFloat32Value * kFloat32ToSInt16));
++outOutputBuffer;
--inNumberSamples;
}
}
static void ClipFloat32ToSInt24LE_4(const Float32* inInputBuffer, SInt32* outOutputBuffer, UInt32 inNumberSamples)
{
register UInt32 theLeftOvers = inNumberSamples % 4;
while(inNumberSamples > theLeftOvers)
{
register Float32 theFloat32Value1 = *(inInputBuffer + 0);
register Float32 theFloat32Value2 = *(inInputBuffer + 1);
register Float32 theFloat32Value3 = *(inInputBuffer + 2);
register Float32 theFloat32Value4 = *(inInputBuffer + 3);
inInputBuffer += 4;
theFloat32Value1 = ClipFloat32ForSInt24(theFloat32Value1);
theFloat32Value2 = ClipFloat32ForSInt24(theFloat32Value2);
theFloat32Value3 = ClipFloat32ForSInt24(theFloat32Value3);
theFloat32Value4 = ClipFloat32ForSInt24(theFloat32Value4);
register UInt32 a = (UInt32)(SInt32)(theFloat32Value1 * kFloat32ToSInt32);
register UInt32 b = (UInt32)(SInt32)(theFloat32Value2 * kFloat32ToSInt32);
register UInt32 c = (UInt32)(SInt32)(theFloat32Value3 * kFloat32ToSInt32);
register UInt32 d = (UInt32)(SInt32)(theFloat32Value4 * kFloat32ToSInt32);
#if defined(__ppc__)
register SInt32 theOutputValue1 = ((a << 16) & 0xFF000000) | (a & 0x00FF0000) | ((a >> 16) & 0x0000FF00) | ((b >> 8) & 0x000000FF); register SInt32 theOutputValue2 = ((b << 8) & 0xFF000000) | ((b >> 8) & 0x00FF0000) | (c & 0x0000FF00) | ((c >> 16) & 0x000000FF);
register SInt32 theOutputValue3 = (c & 0xFF000000) | ((d << 8) & 0x00FF0000) | ((d >> 8) & 0x0000FF00) | ((d >> 24) & 0x000000FF);
#elif defined(__i386__)
register SInt32 theOutputValue1 = ((b << 16) & 0xFF000000) | (a >> 8);
register SInt32 theOutputValue2 = ((c << 8) & 0xFFFF0000) | ((b >> 16) & 0x0000FFFF);
register SInt32 theOutputValue3 = (d & 0xFFFFFF00) | ((c >> 24) & 0x000000FF);
#endif
*(outOutputBuffer + 0) = theOutputValue1;
*(outOutputBuffer + 1) = theOutputValue2;
*(outOutputBuffer + 2) = theOutputValue3;
outOutputBuffer += 3;
inNumberSamples -= 4;
}
SInt8* theOutputBuffer = (SInt8*)outOutputBuffer;
while(inNumberSamples > 0)
{
register Float32 theFloat32Value = *inInputBuffer;
++inInputBuffer;
theFloat32Value = ClipFloat32ForSInt24(theFloat32Value);
register SInt32 theSInt32Value = (SInt32)(theFloat32Value * kFloat32ToSInt32);
*(theOutputBuffer + 0) = (SInt8)((((UInt32)theSInt32Value) >> 8) & 0x000000FF);
*(theOutputBuffer + 1) = (SInt8)((((UInt32)theSInt32Value) >> 16) & 0x000000FF);
*(theOutputBuffer + 2) = (SInt8)((((UInt32)theSInt32Value) >> 24) & 0x000000FF);
theOutputBuffer += 3;
--inNumberSamples;
}
}
static void ClipFloat32ToSInt32LE_4(const Float32* inInputBuffer, SInt32* outOutputBuffer, UInt32 inNumberSamples)
{
register UInt32 theLeftOvers = inNumberSamples % 4;
while(inNumberSamples > theLeftOvers)
{
register Float32 theFloat32Value1 = *(inInputBuffer + 0);
register Float32 theFloat32Value2 = *(inInputBuffer + 1);
register Float32 theFloat32Value3 = *(inInputBuffer + 2);
register Float32 theFloat32Value4 = *(inInputBuffer + 3);
inInputBuffer += 4;
theFloat32Value1 = ClipFloat32ForSInt32(theFloat32Value1);
theFloat32Value2 = ClipFloat32ForSInt32(theFloat32Value2);
theFloat32Value3 = ClipFloat32ForSInt32(theFloat32Value3);
theFloat32Value4 = ClipFloat32ForSInt32(theFloat32Value4);
*(outOutputBuffer + 0) = SInt32NativeToLittleEndian((SInt32)(theFloat32Value1 * kFloat32ToSInt32));
*(outOutputBuffer + 1) = SInt32NativeToLittleEndian((SInt32)(theFloat32Value2 * kFloat32ToSInt32));
*(outOutputBuffer + 2) = SInt32NativeToLittleEndian((SInt32)(theFloat32Value3 * kFloat32ToSInt32));
*(outOutputBuffer + 3) = SInt32NativeToLittleEndian((SInt32)(theFloat32Value4 * kFloat32ToSInt32));
outOutputBuffer += 4;
inNumberSamples -= 4;
}
while(inNumberSamples > 0)
{
register Float32 theFloat32Value = *inInputBuffer;
++inInputBuffer;
theFloat32Value = ClipFloat32ForSInt32(theFloat32Value);
*outOutputBuffer = SInt32NativeToLittleEndian((SInt32)(theFloat32Value * kFloat32ToSInt32));
++outOutputBuffer;
--inNumberSamples;
}
}
#endif
IOReturn clipAppleUSBAudioToOutputStream(const void* mixBuf, void* sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat)
{
if(!streamFormat)
{
return kIOReturnBadArgument;
}
UInt32 theNumberSamples = numSampleFrames * streamFormat->fNumChannels;
UInt32 theFirstSample = firstSampleFrame * streamFormat->fNumChannels;
Float32* theMixBuffer = ((Float32*)mixBuf) + theFirstSample;
switch(streamFormat->fBitWidth)
{
case 8:
{
SInt8* theOutputBufferSInt8 = ((SInt8*)sampleBuf) + theFirstSample;
#if defined(__ppc__)
Float32ToInt8(theMixBuffer, theOutputBufferSInt8, theNumberSamples);
#elif defined(__i386__)
ClipFloat32ToSInt8_4(theMixBuffer, theOutputBufferSInt8, theNumberSamples);
#endif
}
break;
case 16:
{
SInt16* theOutputBufferSInt16 = ((SInt16*)sampleBuf) + theFirstSample;
#if defined(__ppc__)
Float32ToSwapInt16(theMixBuffer, theOutputBufferSInt16, theNumberSamples);
#elif defined(__i386__)
ClipFloat32ToSInt16LE_4(theMixBuffer, theOutputBufferSInt16, theNumberSamples);
#endif
}
break;
case 20:
case 24:
{
SInt32* theOutputBufferSInt24 = (SInt32*)(((UInt8*)sampleBuf) + (theFirstSample * 3));
#if defined(__ppc__)
Float32ToSwapInt24(theMixBuffer, theOutputBufferSInt24, theNumberSamples);
#elif defined(__i386__)
ClipFloat32ToSInt24LE_4(theMixBuffer, theOutputBufferSInt24, theNumberSamples);
#endif
}
break;
case 32:
{
SInt32* theOutputBufferSInt32 = ((SInt32*)sampleBuf) + theFirstSample;
#if defined(__ppc__)
Float32ToSwapInt32(theMixBuffer, theOutputBufferSInt32, theNumberSamples);
#elif defined(__i386__)
ClipFloat32ToSInt32LE_4(theMixBuffer, theOutputBufferSInt32, theNumberSamples);
#endif
}
break;
};
return kIOReturnSuccess;
}
IOReturn clipAppleUSBAudioToOutputStreamiSub (const void *mixBuf, void *sampleBuf, PreviousValues * filterState, PreviousValues * filterState2, PreviousValues * phaseCompState, Float32 *low, Float32 *high, UInt32 firstSampleFrame, UInt32 numSampleFrames, UInt32 sampleRate, const IOAudioStreamFormat *streamFormat, SInt16 *iSubBufferMemory, UInt32 *loopCount, SInt32 *iSubBufferOffset, UInt32 iSubBufferLen, iSubAudioFormatType* iSubFormat, float* srcPhase, float* srcState)
{
UInt32 sampleIndex, maxSampleIndex;
float *floatMixBuf;
SInt16 *outputBuf;
float highSample;
Float32 iSubSampleFloat;
SInt16 iSubSampleInt;
float x0, x1, temp;
float phaseInc = ((float)sampleRate)/((float)(iSubFormat->outputSampleRate)); float phase = *srcPhase;
floatMixBuf = (float *)mixBuf;
outputBuf = (SInt16 *)sampleBuf;
maxSampleIndex = (firstSampleFrame + numSampleFrames) * (streamFormat->fNumChannels);
if (1 == streamFormat->fNumChannels)
{
MonoFilter (&floatMixBuf[firstSampleFrame * streamFormat->fNumChannels], &low[firstSampleFrame * streamFormat->fNumChannels], &high[firstSampleFrame * streamFormat->fNumChannels], numSampleFrames, sampleRate);
}
else if (2 == streamFormat->fNumChannels)
{
StereoFilter4thOrderPhaseComp (&floatMixBuf[firstSampleFrame * streamFormat->fNumChannels], &low[firstSampleFrame * streamFormat->fNumChannels], &high[firstSampleFrame * streamFormat->fNumChannels], numSampleFrames, sampleRate, filterState, filterState2, phaseCompState);
}
for (sampleIndex = (firstSampleFrame * streamFormat->fNumChannels); sampleIndex < maxSampleIndex; sampleIndex++)
{
highSample = high[sampleIndex];
if (highSample > 1.0)
{
highSample = 1.0;
}
else if (highSample < -1.0)
{
highSample = -1.0;
}
outputBuf[sampleIndex] = OSSwapHostToLittleInt16 ((SInt16)(highSample * 32767.0));
}
if ((iSubFormat->numChannels == 1) && (streamFormat->fNumChannels == 2))
{
sampleIndex = (firstSampleFrame * streamFormat->fNumChannels);
while (sampleIndex < maxSampleIndex)
{
if (phase >= 1.0)
{
phase -= 1.0;
sampleIndex+=2;
}
else
{
if (sampleIndex == (firstSampleFrame * streamFormat->fNumChannels))
{
x0 = *srcState;
}
else
{
x0 = low[sampleIndex-2];
temp = low[sampleIndex-1];
x0 = 0.5*(x0 + temp);
}
x1 = low[sampleIndex];
temp = low[sampleIndex+1];
x1 = 0.5*(x1 + temp);
iSubSampleFloat = x0 + phase*(x1 - x0);
if (iSubSampleFloat > 1.0)
{
iSubSampleFloat = 1.0;
}
else if (iSubSampleFloat < -1.0)
{
iSubSampleFloat = -1.0;
}
if (iSubSampleFloat >= 0)
{
iSubSampleInt = (SInt16) (iSubSampleFloat * 32767.0);
}
else
{
iSubSampleInt = (SInt16) (iSubSampleFloat * 32768.0);
}
if (*iSubBufferOffset >= (SInt32)iSubBufferLen)
{
*iSubBufferOffset = 0;
(*loopCount)++;
}
iSubBufferMemory[(*iSubBufferOffset)++] = OSSwapLittleToHostInt16(iSubSampleInt);
phase += phaseInc;
}
}
if (phase < 1)
{
x1 = low[maxSampleIndex-2];
temp = low[maxSampleIndex-1];
*srcState = 0.5*(x1 + temp);
}
else
{
*srcState = 0;
}
*srcPhase = phase;
}
else
{
for (sampleIndex = (firstSampleFrame * streamFormat->fNumChannels); sampleIndex < maxSampleIndex; sampleIndex++)
{
iSubSampleFloat = low[sampleIndex];
if (iSubSampleFloat > 1.0)
{
iSubSampleFloat = 1.0;
}
else if (iSubSampleFloat < -1.0)
{
iSubSampleFloat = -1.0;
}
iSubSampleInt = (SInt16) (iSubSampleFloat * 32767.0);
if (*iSubBufferOffset >= (SInt32)iSubBufferLen)
{
*iSubBufferOffset = 0;
(*loopCount)++;
}
iSubBufferMemory[(*iSubBufferOffset)++] = OSSwapLittleToHostInt16(iSubSampleInt);
}
}
return kIOReturnSuccess;
}
const float kOneOverMaxSInt8Value = 1.0/128.0f;
const float kOneOverMaxSInt16Value = 1.0/32768.0f;
const float kOneOverMaxSInt24Value = 0.00000011920928955078125f;
const float kOneOverMaxSInt32Value = 1.0/2147483648.0f;
IOReturn convertFromAppleUSBAudioInputStream_NoWrap (const void *sampleBuf,
void *destBuf,
UInt32 firstSampleFrame,
UInt32 numSampleFrames,
const IOAudioStreamFormat *streamFormat) {
UInt32 numSamplesLeft;
float *floatDestBuf;
floatDestBuf = (float *)destBuf;
numSamplesLeft = numSampleFrames * streamFormat->fNumChannels;
switch (streamFormat->fBitWidth)
{
case 8:
SInt8 *inputBuf8;
inputBuf8 = &(((SInt8 *)sampleBuf)[firstSampleFrame * streamFormat->fNumChannels]);
#if defined(__ppc__)
Int8ToFloat32(inputBuf8, floatDestBuf, numSamplesLeft);
#elif defined(__i386__)
while (numSamplesLeft-- > 0)
{
*(floatDestBuf++) = (float)(*(inputBuf8++)) * kOneOverMaxSInt8Value;
}
#endif
break;
case 16:
SInt16 *inputBuf16;
inputBuf16 = &(((SInt16 *)sampleBuf)[firstSampleFrame * streamFormat->fNumChannels]);
#if defined(__ppc__)
SwapInt16ToFloat32(inputBuf16, floatDestBuf, numSamplesLeft, 16);
#elif defined(__i386__)
while (numSamplesLeft-- > 0)
{
*(floatDestBuf++) = (float)(*(inputBuf16++)) * kOneOverMaxSInt16Value;
}
#endif
break;
case 20:
case 24:
register SInt8 *inputBuf24;
inputBuf24 = &(((SInt8 *)sampleBuf)[firstSampleFrame * streamFormat->fNumChannels * 3]);
#if defined(__ppc__)
SwapInt24ToFloat32((long *)inputBuf24, floatDestBuf, numSamplesLeft, 24);
#elif defined(__i386__)
register SInt32 inputSample;
while (numSamplesLeft-- > 1)
{
inputSample = (* (UInt32 *)inputBuf24) & 0x00FFFFFF;
if (inputSample > 0x7FFFFF)
{
inputSample |= 0xFF000000;
}
inputBuf24 += 3;
*(floatDestBuf++) = (float)inputSample * kOneOverMaxSInt24Value;
}
inputSample = SInt32 ((UInt32 (*(UInt16 *) inputBuf24) & 0x0000FFFF) | (SInt32 (*(inputBuf24 + 2)) << 16));
*(floatDestBuf++) = (float)inputSample * kOneOverMaxSInt24Value;
#endif
break;
case 32:
register SInt32 *inputBuf32;
inputBuf32 = &(((SInt32 *)sampleBuf)[firstSampleFrame * streamFormat->fNumChannels]);
#if defined(__ppc__)
SwapInt32ToFloat32(inputBuf32, floatDestBuf, numSamplesLeft, 32);
#elif defined(__i386__)
while (numSamplesLeft-- > 0) {
*(floatDestBuf++) = (float)(*(inputBuf32++)) * kOneOverMaxSInt32Value;
}
#endif
break;
}
return kIOReturnSuccess;
}
#if FLOATLIB
void CoeffsFilterOrder2 (Float32 *Coeff, Float32 CutOffFreq, Float32 AttAtCutOffFreq , Float64 SamplingRate)
{
Float32 k, nu0, pi=3.14159, Att, norm;
nu0 = (Float32) (CutOffFreq / SamplingRate);
Att = 1 / AttAtCutOffFreq;
k = 1/(tan(pi*nu0));
norm = k*(k+Att)+1;
Coeff[0] = 1.0 / norm;
Coeff[1] = 2.0 / norm;
Coeff[2] = 1.0 / norm;
Coeff[3] = 2*(1-k*k) / norm;
Coeff[4] = (k*(k-Att)+1) / norm;
return;
}
#else
Boolean CoeffsFilterOrder2Table (Float32 *Coeff, UInt32 samplingRate)
{
Boolean success = TRUE;
switch ( samplingRate )
{
case 8000: Coeff[0] = 0.00208054389804601669;
Coeff[1] = 0.00416108779609203339;
Coeff[2] = 0.00208054389804601669;
Coeff[3] = -1.86687481403350830078;
Coeff[4] = 0.87519699335098266602;
break;
case 11025: Coeff[0] = 0.00111490569543093443;
Coeff[1] = 0.00222981139086186886;
Coeff[2] = 0.00111490569543093443;
Coeff[3] = -1.90334117412567138672;
Coeff[4] = 0.90780085325241088867;
break;
case 22050: Coeff[0] = 0.00028538206242956221;
Coeff[1] = 0.00057076412485912442;
Coeff[2] = 0.00028538206242956221;
Coeff[3] = -1.95164430141448974609;
Coeff[4] = 0.95278578996658325195;
break;
case 44100: Coeff[0] = 0.00007220284896902740;
Coeff[1] = 0.00014440569793805480;
Coeff[2] = 0.00007220284896902740;
Coeff[3] = -1.97581851482391357422;
Coeff[4] = 0.97610741853713989258;
break;
case 48000: Coeff[0] = 0.00006100598693592474;
Coeff[1] = 0.00012201197387184948;
Coeff[2] = 0.00006100598693592474;
Coeff[3] = -1.97778332233428955078;
Coeff[4] = 0.97802722454071044922;
break;
case 96000: Coeff[0] = 0.00001533597242087126;
Coeff[1] = 0.00003067194484174252;
Coeff[2] = 0.00001533597242087126;
Coeff[3] = -1.98889136314392089844;
Coeff[4] = 0.98895263671875000000;
break;
default: success = FALSE;
break;
}
return(success);
}
#endif
Boolean Set4thOrderCoefficients (Float32 *b0, Float32 *b1, Float32 *b2, Float32 *a1, Float32 *a2, UInt32 samplingRate)
{
Boolean success = TRUE;
switch ( samplingRate )
{
case 8000: *b0 = 0.00782020803350;
*b1 = 0.01564041606699;
*b2 = 0.00782020803350;
*a1 = -1.73472576880928;
*a2 = 0.76600660094326;
break;
case 11025: *b0 = 0.00425905333005;
*b1 = 0.00851810666010;
*b2 = 0.00425905333005;
*a1 = -1.80709136077571;
*a2 = 0.82412757409590;
break;
case 22050: *b0 = 0.00111491512001;
*b1 = 0.00222983024003;
*b2 = 0.00111491512001;
*a1 = -1.90335434048751;
*a2 = 0.90781400096756;
break;
case 44100: *b0 = 0.00028538351548666;
*b1 = 0.00057076703097332;
*b2 = 0.00028538351548666;
*a1 = -1.95165117996464;
*a2 = 0.95279271402659;
break;
case 48000: *b0 = 0.00024135904904198;
*b1 = 0.00048271809808396;
*b2 = 0.00024135904904198;
*a1 = -1.95557824031504;
*a2 = 0.95654367651120;
break;
case 96000: *b0 = 0.00006100617875806425;
*b1 = 0.0001220123575161285;
*b2 = 0.00006100617875806425;
*a1 = -1.977786483776763;
*a2 = 0.9780305084917958;
break;
default: success = FALSE;
break;
}
return(success);
}
Boolean Set4thOrderPhaseCompCoefficients (Float32 *b0, Float32 *b1, Float32 *a1, Float32 *a2, UInt32 samplingRate)
{
Boolean success = TRUE;
switch ( samplingRate )
{
case 8000: *a1 = -1.734725768809275;
*a2 = 0.7660066009432638;
*b0 = *a2;
*b1 = *a1;
break;
case 11025: *a1 = -1.807091360775707;
*a2 = 0.8241275740958973;
*b0 = *a2;
*b1 = *a1;
break;
case 22050: *a1 = -1.903354340487510;
*a2 = 0.9078140009675627;
*b0 = *a2;
*b1 = *a1;
break;
case 44100: *a1 = -1.951651179964643;
*a2 = 0.9527927140265903;
*b0 = *a2;
*b1 = *a1;
break;
case 48000: *a1 = -1.955578240315035;
*a2 = 0.9565436765112033;
*b0 = *a2;
*b1 = *a1;
break;
case 96000: *a1 = -1.977786483776763;
*a2 = 0.9780305084917958;
*b0 = *a2;
*b1 = *a1;
break;
default: success = FALSE;
break;
}
return(success);
}
Boolean Set2ndOrderPhaseCompCoefficients (float *b0, float *a1, UInt32 samplingRate)
{
Boolean success = TRUE;
switch ( samplingRate )
{
case 8000: *a1 = -0.7324848836653277;
*b0 = *a1;
break;
case 11025: *a1 = -0.7985051758519318;
*b0 = *a1;
break;
case 22050: *a1 = -0.8939157008398341;
*b0 = *a1;
break;
case 44100: *a1 = -0.9455137594199962;
*b0 = *a1;
break;
case 48000: *a1 = -0.9498297607998617;
*b0 = *a1;
break;
case 96000: *a1 = -0.9745963490718829;
*b0 = *a1;
break;
default: success = FALSE;
break;
}
return(success);
}
void MonoFilter (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 samplingRate)
{
UInt32 idx;
#if !FLOATLIB
Boolean success;
#endif
Float32 LP_Coeff[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
Float32 x, xx, xxx, y, yy, yyy;
#if FLOATLIB
CoeffsFilterOrder2 (LP_Coeff, 120, 1/sqrt(2), 44100);
#else
success = CoeffsFilterOrder2Table (LP_Coeff, samplingRate);
if (success == FALSE) goto End;
#endif
x=xx=xxx=y=yy=yyy=0;
for ( idx = 0 ; idx < frames ; idx++ )
{
x = in[idx];
y = (LP_Coeff[0]*x + LP_Coeff[1]*xx + LP_Coeff[2]*xxx - LP_Coeff[3]*yy - LP_Coeff[4]*yyy);
xxx = xx;
xx = x;
yyy = yy;
yy = y;
low[idx] = y;
high[idx] = x-y;
}
#if !FLOATLIB
End:
#endif
return;
}
void StereoFilter (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 SamplingRate, PreviousValues *theValue)
{
UInt32 idx;
Boolean success;
Float32 LP_Coeff[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
Float32 xl, xr, yl, yr;
success = CoeffsFilterOrder2Table (LP_Coeff, SamplingRate);
if (success == FALSE) goto End;
for ( idx = 0 ; idx < frames ; idx ++ )
{
xl = in[2*idx];
xr = in[2*idx+1];
yl = (LP_Coeff[0]*xl + LP_Coeff[1]*theValue->xl_1 + LP_Coeff[2]*theValue->xl_2 - LP_Coeff[3]*theValue->yl_1 - LP_Coeff[4]*theValue->yl_2);
yr = (LP_Coeff[0]*xr + LP_Coeff[1]*theValue->xr_1 + LP_Coeff[2]*theValue->xr_2 - LP_Coeff[3]*theValue->yr_1 - LP_Coeff[4]*theValue->yr_2);
theValue->xl_2 = theValue->xl_1;
theValue->xr_2 = theValue->xr_1;
theValue->xl_1 = xl;
theValue->xr_1 = xr;
theValue->yl_2 = theValue->yl_1;
theValue->yr_2 = theValue->yr_1;
theValue->yl_1 = yl;
theValue->yr_1 = yr;
low[2*idx] = yl;
low[2*idx+1] = yr;
high[2*idx] = xl-yl;
high[2*idx+1] = xr-yr;
}
End:
return;
}
}
void StereoFilter4thOrder (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 SamplingRate, PreviousValues *theValue, PreviousValues *theValue2)
{
UInt32 i;
Float32 inL, inR, outL1, outR1, outL, outR;
Float32 b0 = 0.0, b1 = 0.0, b2 = 0.0, a1 = 0.0, a2 = 0.0;
Float32 inLTap1, inLTap2, inRTap1, inRTap2;
Float32 outLTap1, outLTap2, outRTap1, outRTap2;
Float32 inLTap1_2, inLTap2_2, inRTap1_2, inRTap2_2;
Float32 outLTap1_2, outLTap2_2, outRTap1_2, outRTap2_2;
inLTap1 = theValue->xl_1;
inLTap2 = theValue->xl_2;
inRTap1 = theValue->xr_1;
inRTap2 = theValue->xr_2;
outLTap1 = theValue->yl_1;
outLTap2 = theValue->yl_2;
outRTap1 = theValue->yr_1;
outRTap2 = theValue->yr_2;
inLTap1_2 = theValue2->xl_1;
inLTap2_2 = theValue2->xl_2;
inRTap1_2 = theValue2->xr_1;
inRTap2_2 = theValue2->xr_2;
outLTap1_2 = theValue2->yl_1;
outLTap2_2 = theValue2->yl_2;
outRTap1_2 = theValue2->yr_1;
outRTap2_2 = theValue2->yr_2;
if (Set4thOrderCoefficients (&b0, &b1, &b2, &a1, &a2, SamplingRate) == FALSE)
return;
for ( i = 0 ; i < frames ; i ++ )
{
inL = in[2*i];
inR = in[2*i+1];
outL1 = (b0*inL + b1*inLTap1 + b2*inLTap2 - a1*outLTap1 - a2*outLTap2);
outR1 = (b0*inR + b1*inRTap1 + b2*inRTap2 - a1*outRTap1 - a2*outRTap2);
inLTap2 = inLTap1;
inRTap2 = inRTap1;
inLTap1 = inL;
inRTap1 = inR;
outLTap2 = outLTap1;
outRTap2 = outRTap1;
outLTap1 = outL1;
outRTap1 = outR1;
outL = (b0*outL1 + b1*inLTap1_2 + b2*inLTap2_2 - a1*outLTap1_2 - a2*outLTap2_2);
outR = (b0*outR1 + b1*inRTap1_2 + b2*inRTap2_2 - a1*outRTap1_2 - a2*outRTap2_2);
inLTap2_2 = inLTap1_2;
inRTap2_2 = inRTap1_2;
inLTap1_2 = outL1;
inRTap1_2 = outR1;
outLTap2_2 = outLTap1_2;
outRTap2_2 = outRTap1_2;
outLTap1_2 = outL;
outRTap1_2 = outR;
low[2*i] = outL;
low[2*i+1] = outR;
high[2*i] = inL-outL;
high[2*i+1] = inR-outR;
}
theValue->xl_1 = inLTap1;
theValue->xl_2 = inLTap2;
theValue->xr_1 = inRTap1;
theValue->xr_2 = inRTap2;
theValue->yl_1 = outLTap1;
theValue->yl_2 = outLTap2;
theValue->yr_1 = outRTap1;
theValue->yr_2 = outRTap2;
theValue2->xl_1 = inLTap1_2;
theValue2->xl_2 = inLTap2_2;
theValue2->xr_1 = inRTap1_2;
theValue2->xr_2 = inRTap2_2;
theValue2->yl_1 = outLTap1_2;
theValue2->yl_2 = outLTap2_2;
theValue2->yr_1 = outRTap1_2;
theValue2->yr_2 = outRTap2_2;
return;
}
void StereoFilter4thOrderPhaseComp (Float32 *in, Float32 *low, Float32 *high, UInt32 frames, UInt32 SamplingRate, PreviousValues *section1State, PreviousValues *section2State, PreviousValues *phaseCompState)
{
UInt32 i;
Float32 inL, inR, outL1, outR1, outL, outR, inPhaseCompL, inPhaseCompR;
Float32 b0 = 0.0, b1 = 0.0, b2 = 0.0, a1 = 0.0, a2 = 0.0;
Float32 bp0 = 0.0, bp1 = 0.0, ap1 = 0.0, ap2 = 0.0;
Float32 inLTap1, inLTap2, inRTap1, inRTap2;
Float32 outLTap1, outLTap2, outRTap1, outRTap2;
Float32 inLTap1_2, inLTap2_2, inRTap1_2, inRTap2_2;
Float32 outLTap1_2, outLTap2_2, outRTap1_2, outRTap2_2;
Float32 inLTap1_p, inLTap2_p, inRTap1_p, inRTap2_p;
Float32 outLTap1_p, outLTap2_p, outRTap1_p, outRTap2_p;
inLTap1 = section1State->xl_1;
inLTap2 = section1State->xl_2;
inRTap1 = section1State->xr_1;
inRTap2 = section1State->xr_2;
outLTap1 = section1State->yl_1;
outLTap2 = section1State->yl_2;
outRTap1 = section1State->yr_1;
outRTap2 = section1State->yr_2;
inLTap1_2 = section2State->xl_1;
inLTap2_2 = section2State->xl_2;
inRTap1_2 = section2State->xr_1;
inRTap2_2 = section2State->xr_2;
outLTap1_2 = section2State->yl_1;
outLTap2_2 = section2State->yl_2;
outRTap1_2 = section2State->yr_1;
outRTap2_2 = section2State->yr_2;
inLTap1_p = phaseCompState->xl_1;
inLTap2_p = phaseCompState->xl_2;
inRTap1_p = phaseCompState->xr_1;
inRTap2_p = phaseCompState->xr_2;
outLTap1_p = phaseCompState->yl_1;
outLTap2_p = phaseCompState->yl_2;
outRTap1_p = phaseCompState->yr_1;
outRTap2_p = phaseCompState->yr_2;
if (Set4thOrderCoefficients (&b0, &b1, &b2, &a1, &a2, SamplingRate) == FALSE)
return;
if (Set4thOrderPhaseCompCoefficients (&bp0, &bp1, &ap1, &ap2, SamplingRate) == FALSE)
return;
for ( i = 0 ; i < frames ; i ++ )
{
inL = in[2*i];
inR = in[2*i+1];
outL1 = b0*inL + b1*inLTap1 + b2*inLTap2 - a1*outLTap1 - a2*outLTap2;
outR1 = b0*inR + b1*inRTap1 + b2*inRTap2 - a1*outRTap1 - a2*outRTap2;
inLTap2 = inLTap1;
inRTap2 = inRTap1;
inLTap1 = inL;
inRTap1 = inR;
outLTap2 = outLTap1;
outRTap2 = outRTap1;
outLTap1 = outL1;
outRTap1 = outR1;
outL = b0*outL1 + b1*inLTap1_2 + b2*inLTap2_2 - a1*outLTap1_2 - a2*outLTap2_2;
outR = b0*outR1 + b1*inRTap1_2 + b2*inRTap2_2 - a1*outRTap1_2 - a2*outRTap2_2;
inLTap2_2 = inLTap1_2;
inRTap2_2 = inRTap1_2;
inLTap1_2 = outL1;
inRTap1_2 = outR1;
outLTap2_2 = outLTap1_2;
outRTap2_2 = outRTap1_2;
outLTap1_2 = outL;
outRTap1_2 = outR;
inPhaseCompL = bp0*inL + bp1*inLTap1_p + inLTap2_p - ap1*outLTap1_p - ap2*outLTap2_p;
inPhaseCompR = bp0*inR + bp1*inRTap1_p + inRTap2_p - ap1*outRTap1_p - ap2*outRTap2_p;
inLTap2_p = inLTap1_p;
inRTap2_p = inRTap1_p;
inLTap1_p = inL;
inRTap1_p = inR;
outLTap2_p = outLTap1_p;
outRTap2_p = outRTap1_p;
outLTap1_p = inPhaseCompL;
outRTap1_p = inPhaseCompR;
low[2*i] = outL;
low[2*i+1] = outR;
high[2*i] = inPhaseCompL-outL;
high[2*i+1] = inPhaseCompR-outR;
}
section1State->xl_1 = inLTap1;
section1State->xl_2 = inLTap2;
section1State->xr_1 = inRTap1;
section1State->xr_2 = inRTap2;
section1State->yl_1 = outLTap1;
section1State->yl_2 = outLTap2;
section1State->yr_1 = outRTap1;
section1State->yr_2 = outRTap2;
section2State->xl_1 = inLTap1_2;
section2State->xl_2 = inLTap2_2;
section2State->xr_1 = inRTap1_2;
section2State->xr_2 = inRTap2_2;
section2State->yl_1 = outLTap1_2;
section2State->yl_2 = outLTap2_2;
section2State->yr_1 = outRTap1_2;
section2State->yr_2 = outRTap2_2;
phaseCompState->xl_1 = inLTap1_p;
phaseCompState->xl_2 = inLTap2_p;
phaseCompState->xr_1 = inRTap1_p;
phaseCompState->xr_2 = inRTap2_p;
phaseCompState->yl_1 = outLTap1_p;
phaseCompState->yl_2 = outLTap2_p;
phaseCompState->yr_1 = outRTap1_p;
phaseCompState->yr_2 = outRTap2_p;
return;
}
#pragma mark ¥¥¥ New clipping routines
#if defined(__ppc__)
#define __lwbrx( index, base ) ({ register long result; __asm__ __volatile__("lwbrx %0, %1, %2" : "=r" (result) : "b%" (index), "r" (base) : "memory" ); result; } )
#define __lhbrx(index, base) \
({ register signed short lhbrxResult; \
__asm__ ("lhbrx %0, %1, %2" : "=r" (lhbrxResult) : "b%" (index), "r" (base) : "memory"); \
lhbrxResult; } )
#define __rlwimi( rA, rS, cnt, mb, me ) \
({ __asm__ __volatile__( "rlwimi %0, %2, %3, %4, %5" : "=r" (rA) : "0" (rA), "r" (rS), "n" (cnt), "n" (mb), "n" (me) ); rA; })
#define __stwbrx( value, index, base ) \
__asm__( "stwbrx %0, %1, %2" : : "r" (value), "b%" (index), "r" (base) : "memory" )
#define __rlwimi_volatile( rA, rS, cnt, mb, me ) \
({ __asm__ __volatile__( "rlwimi %0, %2, %3, %4, %5" : "=r" (rA) : "0" (rA), "r" (rS), "n" (cnt), "n" (mb), "n" (me) ); rA; })
#define __stfiwx( value, offset, addr ) \
asm( "stfiwx %0, %1, %2" : : "f" (value), "b%" (offset), "r" (addr) : "memory" )
static inline double __fctiw( register double B )
{
register double result;
asm( "fctiw %0, %1" : "=f" (result) : "f" (B) );
return result;
}
void Int8ToFloat32( SInt8 *src, float *dest, unsigned int count )
{
register float bias;
register long exponentMask = ((0x97UL - 8) << 23) | 0x8000; register long int0, int1, int2, int3;
register float float0, float1, float2, float3;
register unsigned long loopCount;
union
{
float f;
long i;
}exponent;
exponent.i = exponentMask;
bias = exponent.f;
src--;
if( count >= 8 )
{
int0 = (++src)[0];
int1 = (++src)[0];
int0 += exponentMask;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[0] = int0;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[1] = int1;
int0 = (++src)[0];
int3 += exponentMask;
((long*) dest)[2] = int2;
float0 = dest[0];
int1 = (++src)[0];
int0 += exponentMask;
((long*) dest)[3] = int3;
float1 = dest[1];
float0 -= bias;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[4] = int0;
float2 = dest[2];
float1 -= bias;
dest--;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
count -= 8;
loopCount = count / 4;
count &= 3;
while( loopCount-- )
{
int0 = (++src)[0];
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
int1 = (++src)[0];
int0 += exponentMask;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[6] = int0;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
}
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
float3 -= bias;
(++dest)[0] = float1;
(++dest)[0] = float2;
(++dest)[0] = float3;
dest++;
}
while( count-- )
{
register long value = (++src)[0];
value += exponentMask;
((long*) dest)[0] = value;
dest[0] -= bias;
dest++;
}
}
void NativeInt16ToFloat32( signed short *src, float *dest, unsigned int count, int bitDepth )
{
register float bias;
register long exponentMask = ((0x97UL - bitDepth) << 23) | 0x8000; register long int0, int1, int2, int3;
register float float0, float1, float2, float3;
register unsigned long loopCount;
union
{
float f;
long i;
} exponent;
exponent.i = exponentMask;
bias = exponent.f;
src--;
if( count >= 8 )
{
int0 = (++src)[0];
int1 = (++src)[0];
int0 += exponentMask;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[0] = int0;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[1] = int1;
int0 = (++src)[0];
int3 += exponentMask;
((long*) dest)[2] = int2;
float0 = dest[0];
int1 = (++src)[0];
int0 += exponentMask;
((long*) dest)[3] = int3;
float1 = dest[1];
float0 -= bias;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[4] = int0;
float2 = dest[2];
float1 -= bias;
dest--;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
count -= 8;
loopCount = count / 4;
count &= 3;
while( loopCount-- )
{
int0 = (++src)[0];
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
int1 = (++src)[0];
int0 += exponentMask;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
int2 = (++src)[0];
int1 += exponentMask;
((long*) dest)[6] = int0;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
int3 = (++src)[0];
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
}
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
float3 -= bias;
(++dest)[0] = float1;
(++dest)[0] = float2;
(++dest)[0] = float3;
dest++;
}
while( count-- )
{
register long value = (++src)[0];
value += exponentMask;
((long*) dest)[0] = value;
dest[0] -= bias;
dest++;
}
}
void SwapInt16ToFloat32( signed short *src, float *dest, unsigned int count, int bitDepth )
{
register float bias;
register long exponentMask = ((0x97UL - bitDepth) << 23) | 0x8000; register long int0, int1, int2, int3;
register float float0, float1, float2, float3;
register unsigned long loopCount;
union
{
float f;
long i;
}exponent;
exponent.i = exponentMask;
bias = exponent.f;
src--;
if( count >= 8 )
{
int0 = __lhbrx(0, ++src);
int1 = __lhbrx(0, ++src);
int0 += exponentMask;
int2 = __lhbrx(0, ++src);
int1 += exponentMask;
((long*) dest)[0] = int0;
int3 = __lhbrx(0, ++src);
int2 += exponentMask;
((long*) dest)[1] = int1;
int0 = __lhbrx(0, ++src);
int3 += exponentMask;
((long*) dest)[2] = int2;
float0 = dest[0];
int1 = __lhbrx(0, ++src);
int0 += exponentMask;
((long*) dest)[3] = int3;
float1 = dest[1];
float0 -= bias;
int2 = __lhbrx(0, ++src);
int1 += exponentMask;
((long*) dest)[4] = int0;
float2 = dest[2];
float1 -= bias;
dest--;
int3 = __lhbrx(0, ++src);
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
count -= 8;
loopCount = count / 4;
count &= 3;
while( loopCount-- )
{
int0 = __lhbrx(0, ++src);
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
int1 = __lhbrx(0, ++src);
int0 += exponentMask;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
int2 = __lhbrx(0, ++src);
int1 += exponentMask;
((long*) dest)[6] = int0;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
int3 = __lhbrx(0, ++src);
int2 += exponentMask;
((long*) dest)[6] = int1;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
}
int3 += exponentMask;
((long*) dest)[6] = int2;
float0 = dest[4];
float3 -= bias;
(++dest)[0] = float1;
((long*) dest)[6] = int3;
float1 = dest[4];
float0 -= bias;
(++dest)[0] = float2;
float2 = dest[4];
float1 -= bias;
(++dest)[0] = float3;
float3 = dest[4];
float2 -= bias;
(++dest)[0] = float0;
float3 -= bias;
(++dest)[0] = float1;
(++dest)[0] = float2;
(++dest)[0] = float3;
dest++;
}
while( count-- )
{
register long value = __lhbrx(0, ++src);
value += exponentMask;
((long*) dest)[0] = value;
dest[0] -= bias;
dest++;
}
}
void NativeInt24ToFloat32( long *src, float *dest, unsigned int count, int bitDepth )
{
union
{
double d[4];
unsigned int i[8];
} transfer;
register double dBias;
register unsigned int loopCount, load0SignMask;
register unsigned long load0, load1, load2;
register unsigned long int0, int1, int2, int3;
register double d0, d1, d2, d3;
register float f0, f1, f2, f3;
transfer.i[0] = transfer.i[2] = transfer.i[4] = transfer.i[6] = (0x434UL - bitDepth) << 20; transfer.i[1] = 0x00800000;
int0 = int1 = int2 = int3 = 0;
load0SignMask = 0x80000080UL;
dBias = transfer.d[0];
src--;
dest--;
if( count >= 8 )
{
count -= 8;
loopCount = count / 4;
count &= 3;
load0 = (++src)[0];
load1 = (++src)[0];
load0 ^= load0SignMask;
load2 = (++src)[0];
load1 ^= 0x00008000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15);
load2 ^= 0x00800000UL;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
transfer.i[1] = int0;
load0 = (++src)[0];
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
transfer.i[3] = int1;
load1 = (++src)[0];
load0 ^= load0SignMask;
transfer.i[5] = int2;
d0 = transfer.d[0];
load2 = (++src)[0];
load1 ^= 0x00008000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15 );
transfer.i[7] = int3;
d1 = transfer.d[1];
d0 -= dBias;
load2 ^= 0x00800000UL;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
transfer.i[1] = int0;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
while( loopCount-- )
{
load0 = (++src)[0];
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
transfer.i[3] = int1;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
load1 = (++src)[0];
load0 ^= load0SignMask;
transfer.i[5] = int2;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
load2 = (++src)[0];
load1 ^= 0x00008000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15 );
transfer.i[7] = int3;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
load2 ^= 0x00800000UL;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
transfer.i[1] = int0;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
}
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
transfer.i[3] = int1;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
transfer.i[5] = int2;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
transfer.i[7] = int3;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
f3 = d3;
(++dest)[0] = f2;
(++dest)[0] = f3;
}
src = (long*) ((char*) src + 1 );
while( count-- )
{
int0 = ((unsigned char*)(src = (long*)( (char*) src + 3 )))[0];
int1 = ((unsigned short*)( (char*) src + 1 ))[0];
int0 ^= 0x00000080UL;
int1 = __rlwimi( int1, int0, 16, 8, 15 );
transfer.i[1] = int1;
d0 = transfer.d[0];
d0 -= dBias;
f0 = d0;
(++dest)[0] = f0;
}
}
void SwapInt24ToFloat32( long *src, float *dest, unsigned int count, int bitDepth )
{
union
{
double d[4];
unsigned int i[8];
}transfer;
register double dBias;
register unsigned int loopCount, load2SignMask;
register unsigned long load0, load1, load2;
register unsigned long int0, int1, int2, int3;
register double d0, d1, d2, d3;
register float f0, f1, f2, f3;
transfer.i[0] = transfer.i[2] = transfer.i[4] = transfer.i[6] = 0x41400000UL;
transfer.i[1] = 0x80000000;
int0 = int1 = int2 = int3 = 0;
load2SignMask = 0x80000080UL;
dBias = transfer.d[0];
src--;
dest--;
if( count >= 8 )
{
count -= 8;
loopCount = count / 4;
count &= 3;
load0 = (++src)[0];
load1 = (++src)[0];
load0 ^= 0x00008000;
load2 = (++src)[0];
load1 ^= 0x00800000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15);
load2 ^= load2SignMask;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
__stwbrx( int0, 0, &transfer.i[1]);
load0 = (++src)[0];
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
__stwbrx( int1, 0, &transfer.i[3]);
load1 = (++src)[0];
load0 ^= 0x00008000;
__stwbrx( int2, 0, &transfer.i[5]);
d0 = transfer.d[0];
load2 = (++src)[0];
load1 ^= 0x00800000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15 );
__stwbrx( int3, 0, &transfer.i[7]);
d1 = transfer.d[1];
d0 -= dBias;
load2 ^= load2SignMask;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
__stwbrx( int0, 0, &transfer.i[1]);
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
while( loopCount-- )
{
load0 = (++src)[0];
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
__stwbrx( int1, 0, &transfer.i[3]);
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
load1 = (++src)[0];
load0 ^= 0x00008000;
__stwbrx( int2, 0, &transfer.i[5]);
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
load2 = (++src)[0];
load1 ^= 0x00800000UL;
int0 = load0 >> 8;
int1 = __rlwimi( int1, load0, 16, 8, 15 );
__stwbrx( int3, 0, &transfer.i[7]);
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
load2 ^= load2SignMask;
int1 = __rlwimi( int1, load1, 16, 16, 31);
int2 = __rlwimi( int2, load1, 8, 8, 23 );
__stwbrx( int0, 0, &transfer.i[1]);
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
}
int2 = __rlwimi( int2, load2, 8, 24, 31 );
int3 = load2 & 0x00FFFFFF;
__stwbrx( int1, 0, &transfer.i[3]);
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
__stwbrx( int2, 0, &transfer.i[5]);
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
__stwbrx( int3, 0, &transfer.i[7]);
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
f3 = d3;
(++dest)[0] = f2;
(++dest)[0] = f3;
}
if( count > 0 )
{
int1 = ((unsigned char*) src)[6];
int0 = ((unsigned short*)(++src))[0];
int1 ^= 0x80;
int1 = __rlwimi( int1, int0, 8, 8, 23 );
__stwbrx( int1, 0, &transfer.i[1]);
d0 = transfer.d[0];
d0 -= dBias;
f0 = d0;
(++dest)[0] = f0;
src = (long*) ((char*)src - 1 );
while( --count )
{
int0 = (src = (long*)( (char*) src + 3 ))[0];
int0 ^= 0x80UL;
int0 &= 0x00FFFFFFUL;
__stwbrx( int0, 0, &transfer.i[1]);
d0 = transfer.d[0];
d0 -= dBias;
f0 = d0;
(++dest)[0] = f0;
}
}
}
void NativeInt32ToFloat32( long *src, float *dest, unsigned int count, int bitDepth )
{
union
{
double d[4];
unsigned int i[8];
}transfer;
register double dBias;
register unsigned int loopCount;
register long int0, int1, int2, int3;
register double d0, d1, d2, d3;
register float f0, f1, f2, f3;
transfer.i[0] = transfer.i[2] = transfer.i[4] = transfer.i[6] = (0x434UL - bitDepth) << 20;
transfer.i[1] = 0x80000000;
dBias = transfer.d[0];
src--;
dest--;
if( count >= 8 )
{
count -= 8;
loopCount = count / 4;
count &= 3;
int0 = (++src)[0];
int1 = (++src)[0];
int0 ^= 0x80000000UL;
int2 = (++src)[0];
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
int3 = (++src)[0];
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
int0 = (++src)[0];
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
int1 = (++src)[0];
int0 ^= 0x80000000UL;
transfer.i[7] = int3;
d0 = transfer.d[0];
int2 = (++src)[0];
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
d1 = transfer.d[1];
d0 -= dBias;
int3 = (++src)[0];
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
while( loopCount-- )
{
int0 = (++src)[0];
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
int1 = (++src)[0];
int0 ^= 0x80000000UL;
transfer.i[7] = int3;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
int2 = (++src)[0];
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
int3 = (++src)[0];
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
}
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
transfer.i[7] = int3;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
f3 = d3;
(++dest)[0] = f2;
(++dest)[0] = f3;
}
while( count-- )
{
int0 = (++src)[0];
int0 ^= 0x80000000UL;
transfer.i[1] = int0;
d0 = transfer.d[0];
d0 -= dBias;
f0 = d0;
(++dest)[0] = f0;
}
}
void SwapInt32ToFloat32( long *src, float *dest, unsigned int count, int bitDepth )
{
union
{
double d[4];
unsigned int i[8];
}transfer;
register double dBias;
register unsigned int loopCount;
register long int0, int1, int2, int3;
register double d0, d1, d2, d3;
register float f0, f1, f2, f3;
transfer.i[0] = transfer.i[2] = transfer.i[4] = transfer.i[6] = (0x434UL - bitDepth) << 20;
transfer.i[1] = 0x80000000;
dBias = transfer.d[0];
src--;
dest--;
if( count >= 8 )
{
count -= 8;
loopCount = count / 4;
count &= 3;
int0 = __lwbrx( 0, ++src);
int1 = __lwbrx( 0, ++src);
int0 ^= 0x80000000UL;
int2 = __lwbrx( 0, ++src);
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
int3 = __lwbrx( 0, ++src);
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
int0 = __lwbrx( 0, ++src);
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
int1 = __lwbrx( 0, ++src);
int0 ^= 0x80000000UL;
transfer.i[7] = int3;
d0 = transfer.d[0];
int2 = __lwbrx( 0, ++src);
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
d1 = transfer.d[1];
d0 -= dBias;
int3 = __lwbrx( 0, ++src);
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
while( loopCount-- )
{
int0 = __lwbrx( 0, ++src);
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
int1 = __lwbrx( 0, ++src);
int0 ^= 0x80000000UL;
transfer.i[7] = int3;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
int2 = __lwbrx( 0, ++src);
int1 ^= 0x80000000UL;
transfer.i[1] = int0;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
int3 = __lwbrx( 0, ++src);
int2 ^= 0x80000000UL;
transfer.i[3] = int1;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
}
int3 ^= 0x80000000UL;
transfer.i[5] = int2;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
transfer.i[7] = int3;
d0 = transfer.d[0];
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
d1 = transfer.d[1];
d0 -= dBias;
f3 = d3;
(++dest)[0] = f2;
d2 = transfer.d[2];
d1 -= dBias;
f0 = d0;
(++dest)[0] = f3;
d3 = transfer.d[3];
d2 -= dBias;
f1 = d1;
(++dest)[0] = f0;
d3 -= dBias;
f2 = d2;
(++dest)[0] = f1;
f3 = d3;
(++dest)[0] = f2;
(++dest)[0] = f3;
}
while( count-- )
{
int0 = __lwbrx( 0, ++src);
int0 ^= 0x80000000UL;
transfer.i[1] = int0;
d0 = transfer.d[0];
d0 -= dBias;
f0 = d0;
(++dest)[0] = f0;
}
}
void Float32ToInt8( float *src, SInt8 *dst, unsigned int count )
{
register double scale = 2147483648.0;
register double round = 128.0;
unsigned long loopCount = count / 4;
long buffer[2];
register float startingFloat;
register double scaled;
register double converted;
register SInt8 copy;
if( count >= 6 )
{
startingFloat = (src++)[0];
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
copy = ((SInt8*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
count -= 6;
loopCount = count / 2;
count &= 1;
while( loopCount-- )
{
register float startingFloat2;
register double scaled2;
register double converted2;
register SInt8 copy2;
(dst++)[0] = copy;
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) );
copy2 = ((SInt8*) buffer)[4];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled2) : "f" ( startingFloat), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted), "b%" (sizeof(float)), "r" (buffer) : "memory" );
startingFloat2 = (src++)[0];
(dst++)[0] = copy2;
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) );
copy = ((SInt8*) buffer)[0];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled) : "f" ( startingFloat2), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted2), "b%" (0), "r" (buffer) : "memory" );
startingFloat = (src++)[0];
}
(dst++)[0] = copy;
copy = ((SInt8*) buffer)[4];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
(dst++)[0] = copy;
copy = ((SInt8*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
(dst++)[0] = copy;
copy = ((SInt8*) buffer)[4];
__stfiwx( converted, sizeof(float), buffer );
(dst++)[0] = copy;
copy = ((SInt8*) buffer)[0];
(dst++)[0] = copy;
copy = ((SInt8*) buffer)[4];
(dst++)[0] = copy;
}
while( count-- )
{
double scaled = src[0] * scale + round;
double converted = __fctiw( scaled );
__stfiwx( converted, 0, buffer );
dst[0] = buffer[0] >> 24;
src++;
dst++;
}
}
void Float32ToNativeInt16( float *src, signed short *dst, unsigned int count )
{
register double scale = 2147483648.0;
register double round = 32768.0;
unsigned long loopCount = count / 4;
long buffer[2];
register float startingFloat;
register double scaled;
register double converted;
register short copy;
if( count >= 6 )
{
startingFloat = (src++)[0];
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
copy = ((short*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
count -= 6;
loopCount = count / 2;
count &= 1;
while( loopCount-- )
{
register float startingFloat2;
register double scaled2;
register double converted2;
register short copy2;
(dst++)[0] = copy;
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) );
copy2 = ((short*) buffer)[2];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled2) : "f" ( startingFloat), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted), "b%" (sizeof(float)), "r" (buffer) : "memory" );
startingFloat2 = (src++)[0];
(dst++)[0] = copy2;
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) );
copy = ((short*) buffer)[0];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled) : "f" ( startingFloat2), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted2), "b%" (0), "r" (buffer) : "memory" );
startingFloat = (src++)[0];
}
(dst++)[0] = copy;
copy = ((short*) buffer)[2];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
(dst++)[0] = copy;
copy = ((short*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
(dst++)[0] = copy;
copy = ((short*) buffer)[2];
__stfiwx( converted, sizeof(float), buffer );
(dst++)[0] = copy;
copy = ((short*) buffer)[0];
(dst++)[0] = copy;
copy = ((short*) buffer)[2];
(dst++)[0] = copy;
}
while( count-- )
{
double scaled = src[0] * scale + round;
double converted = __fctiw( scaled );
__stfiwx( converted, 0, buffer );
dst[0] = buffer[0] >> 16;
src++;
dst++;
}
}
void Float32ToSwapInt16( float *src, signed short *dst, unsigned int count )
{
register double scale = 2147483648.0;
register double round = 32768.0;
unsigned long loopCount = count / 4;
long buffer[2];
register float startingFloat;
register double scaled;
register double converted;
register short copy;
if( count >= 6 )
{
startingFloat = (src++)[0];
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
copy = ((short*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (src++)[0];
count -= 6;
loopCount = count / 2;
count &= 1;
while( loopCount-- )
{
register float startingFloat2;
register double scaled2;
register double converted2;
register short copy2;
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) );
copy2 = ((short*) buffer)[2];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled2) : "f" ( startingFloat), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted), "b%" (sizeof(float)), "r" (buffer) : "memory" );
startingFloat2 = (src)[0]; src+=2;
dst+=2;
__asm__ __volatile__ ( "sthbrx %0, %1, %2" : : "r" (copy2), "r" (-2), "r" (dst) );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) );
copy = ((short*) buffer)[0];
__asm__ __volatile__ ( "fmadd %0, %1, %2, %3" : "=f" (scaled) : "f" ( startingFloat2), "f" (scale), "f" (round) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted2), "b%" (0), "r" (buffer) : "memory" );
startingFloat = (src)[-1];
}
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = ((short*) buffer)[2];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = ((short*) buffer)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = ((short*) buffer)[2];
__stfiwx( converted, sizeof(float), buffer );
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = ((short*) buffer)[0];
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = ((short*) buffer)[2];
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
}
while( count-- )
{
double scaled = src[0] * scale + round;
double converted = __fctiw( scaled );
__stfiwx( converted, 0, buffer );
copy = buffer[0] >> 16;
__asm__ __volatile__ ( "sthbrx %0, 0, %1" : : "r" (copy), "r" (dst) );
src++;
dst++;
}
}
void Float32ToNativeInt24( float *src, signed long *dst, unsigned int count )
{
register double scale = 2147483648.0;
register double round = 0.5 * 256.0;
unsigned long loopCount = count / 4;
long buffer[4];
register float startingFloat, startingFloat2;
register double scaled, scaled2;
register double converted, converted2;
register long copy1; register long copy2; register long copy3; register long copy4; register double oldSetting;
{
union
{
double d;
int i[2];
}setting;
register double newSetting;
asm volatile ( "mffs %0" : "=f" ( oldSetting ) );
setting.d = oldSetting;
setting.i[1] |= 3;
newSetting = setting.d;
asm volatile( "mtfsf 7, %0" : : "f" (newSetting ) );
}
src--;
dst--;
if( count >= 8 )
{
startingFloat = (++src)[0];
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy1 = buffer[0];
__stfiwx( converted, 2 * sizeof( float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy2 = buffer[1];
__stfiwx( converted, 3 * sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy1 = __rlwimi( copy1, copy2, 8, 24, 31 );
copy3 = buffer[2];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
count -= 8;
loopCount = count / 4;
count &= 3;
while( loopCount-- )
{
__asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled2) : "f" (startingFloat), "f" ( scale ), "f" ( round )); startingFloat2 = (++src)[0]; __asm__ __volatile__( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) ); copy4 = buffer[3]; copy2 = __rlwimi_volatile( copy2, copy3, 8, 24, 7 ); __stfiwx( converted, 1 * sizeof(float), buffer );
__asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled) : "f" (startingFloat2), "f" ( scale ), "f" ( round )); startingFloat = (++src)[0]; __asm__ __volatile__( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) ); (++dst)[0] = copy1; copy3 = __rlwimi_volatile( copy3, copy4, 8, 24, 15 ); copy1 = buffer[0]; copy2 = __rlwimi_volatile( copy2, copy2, 8, 0, 31 ); __stfiwx( converted2, 2 * sizeof(float), buffer );
__asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled2) : "f" (startingFloat), "f" ( scale ), "f" ( round )); startingFloat2 = (++src)[0]; converted2 = __fctiw( scaled ); (++dst)[0] = copy2; copy3 = __rlwimi_volatile( copy3, copy3, 16, 0, 31 ); copy2 = buffer[1]; __stfiwx( converted, 3 * sizeof(float), buffer );
__asm__ ( "fmadds %0, %1, %2, %3" : "=f"(scaled) : "f" (startingFloat2), "f" ( scale ), "f" ( round )); startingFloat = (++src)[0]; converted = __fctiw( scaled2 ); (++dst)[0] = copy3; copy1 = __rlwimi_volatile( copy1, copy2, 8, 24, 31 ); __stfiwx( converted2, 0 * sizeof(float), buffer ); copy3 = buffer[2]; }
copy2 = __rlwimi( copy2, copy3, 8, 24, 7 ); copy4 = buffer[3]; __stfiwx( converted, 1 * sizeof(float), buffer ); converted2 = __fctiw( scaled ); scaled2 = startingFloat * scale + round;
(++dst)[0] = copy1; copy2 = __rlwimi( copy2, copy2, 8, 0, 31 ); copy3 = __rlwimi( copy3, copy4, 8, 24, 15 ); copy1 = buffer[0]; __stfiwx( converted2, 2 * sizeof(float), buffer ); converted = __fctiw( scaled2 );
(++dst)[0] = copy2; copy3 = __rlwimi( copy3, copy3, 16, 0, 31 ); copy2 = buffer[1]; __stfiwx( converted, 3 * sizeof(float), buffer );
(++dst)[0] = copy3; copy1 = __rlwimi( copy1, copy2, 8, 24, 31 ); copy3 = buffer[2];
copy2 = __rlwimi( copy2, copy3, 8, 24, 7 ); copy4 = buffer[3];
(++dst)[0] = copy1; copy2 = __rlwimi( copy2, copy2, 8, 0, 31 ); copy3 = __rlwimi( copy3, copy4, 8, 24, 15 );
(++dst)[0] = copy2; copy3 = __rlwimi( copy3, copy3, 16, 0, 31 );
(++dst)[0] = copy3; }
dst++;
while( count-- )
{
startingFloat = (++src)[0]; scaled = startingFloat * scale + round; converted = __fctiw( scaled ); __stfiwx( converted, 0, buffer ); copy1 = buffer[0]; ((signed char*) dst)[0] = copy1 >> 24;
dst = (signed long*) ((signed char*) dst + 1 );
((unsigned short*) dst)[0] = copy1 >> 8;
dst = (signed long*) ((unsigned short*) dst + 1 );
}
__asm__ __volatile__ ( "mtfsf 7, %0" : : "f" (oldSetting) );
}
void Float32ToSwapInt24( float *src, signed long *dst, unsigned int count )
{
register double scale = 2147483648.0;
register double round = 0.5 * 256.0;
unsigned long loopCount = count / 4;
long buffer[4];
register float startingFloat, startingFloat2;
register double scaled, scaled2;
register double converted, converted2;
register long copy1;
register long copy2;
register long copy3;
register long copy4;
register double oldSetting;
{
union
{
double d;
int i[2];
}setting;
register double newSetting;
asm volatile ( "mffs %0" : "=f" ( oldSetting ) );
setting.d = oldSetting;
setting.i[1] |= 3;
newSetting = setting.d;
asm volatile( "mtfsf 7, %0" : : "f" (newSetting ) );
}
src--;
dst--;
if( count >= 8 )
{
startingFloat = (++src)[0];
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy1 = __lwbrx( 0, buffer );
__stfiwx( converted, 2 * sizeof( float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy2 = __lwbrx( 4, buffer );
__stfiwx( converted, 3 * sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
copy1 = __rlwimi( copy1, copy2, 8, 0, 7 );
copy3 = __lwbrx( 8, buffer );;
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale + round;
startingFloat = (++src)[0];
count -= 8;
loopCount = count / 4;
count &= 3;
while( loopCount-- )
{
copy1 = __rlwimi( copy1, copy1, 8, 0, 31 ); __asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled2) : "f" (startingFloat), "f" ( scale ), "f" ( round )); startingFloat2 = (++src)[0]; __asm__ __volatile__( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) ); copy4 = __lwbrx( 12, buffer ); copy2 = __rlwimi_volatile( copy2, copy3, 8, 0, 15 ); __stfiwx( converted, 1 * sizeof(float), buffer );
__asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled) : "f" (startingFloat2), "f" ( scale ), "f" ( round )); startingFloat = (++src)[0]; __asm__ __volatile__( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) ); (++dst)[0] = copy1; copy4 = __rlwimi_volatile( copy4, copy3, 24, 0, 7 ); copy1 = __lwbrx( 0, buffer ); copy2 = __rlwimi_volatile( copy2, copy2, 16, 0, 31 ); __stfiwx( converted2, 2 * sizeof(float), buffer );
__asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled2) : "f" (startingFloat), "f" ( scale ), "f" ( round )); startingFloat2 = (++src)[0]; converted2 = __fctiw( scaled ); (++dst)[0] = copy2; copy2 = __lwbrx( 4, buffer ); __stfiwx( converted, 3 * sizeof(float), buffer );
__asm__ ( "fmadds %0, %1, %2, %3" : "=f"(scaled) : "f" (startingFloat2), "f" ( scale ), "f" ( round )); startingFloat = (++src)[0]; converted = __fctiw( scaled2 ); (++dst)[0] = copy4; copy1 = __rlwimi_volatile( copy1, copy2, 8, 0, 7 ); __stfiwx( converted2, 0 * sizeof(float), buffer ); copy3 = __lwbrx( 8, buffer ); }
copy1 = __rlwimi( copy1, copy1, 8, 0, 31 ); __asm__ __volatile__( "fmadds %0, %1, %2, %3" : "=f"(scaled2) : "f" (startingFloat), "f" ( scale ), "f" ( round )); __asm__ __volatile__( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) ); copy4 = __lwbrx( 12, buffer ); copy2 = __rlwimi_volatile( copy2, copy3, 8, 0, 15 ); __stfiwx( converted, 1 * sizeof(float), buffer );
__asm__ __volatile__( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) ); (++dst)[0] = copy1; copy4 = __rlwimi_volatile( copy4, copy3, 24, 0, 7 ); copy1 = __lwbrx( 0, buffer ); copy2 = __rlwimi_volatile( copy2, copy2, 16, 0, 31 ); __stfiwx( converted2, 2 * sizeof(float), buffer );
(++dst)[0] = copy2; copy2 = __lwbrx( 4, buffer ); __stfiwx( converted, 3 * sizeof(float), buffer );
(++dst)[0] = copy4; copy1 = __rlwimi_volatile( copy1, copy2, 8, 0, 7 ); copy3 = __lwbrx( 8, buffer );
copy1 = __rlwimi( copy1, copy1, 8, 0, 31 ); copy4 = __lwbrx( 12, buffer ); copy2 = __rlwimi_volatile( copy2, copy3, 8, 0, 15 );
(++dst)[0] = copy1; copy4 = __rlwimi_volatile( copy4, copy3, 24, 0, 7 ); copy2 = __rlwimi_volatile( copy2, copy2, 16, 0, 31 );
(++dst)[0] = copy2;
(++dst)[0] = copy4; }
dst++;
while( count-- )
{
startingFloat = (++src)[0]; scaled = startingFloat * scale + round; converted = __fctiw( scaled ); __stfiwx( converted, 0, buffer ); copy1 = __lwbrx( 0, buffer); ((signed char*) dst)[0] = copy1 >> 16;
dst = (signed long*) ((signed char*) dst + 1 );
((unsigned short*) dst)[0] = copy1;
dst = (signed long*) ((unsigned short*) dst + 1 );
}
__asm__ __volatile__ ( "mtfsf 7, %0" : : "f" (oldSetting) );
}
void Float32ToSwapInt32( float *src, signed long *dst, unsigned int count )
{
register double scale = 2147483648.0;
unsigned long loopCount = count / 4;
long buffer[2];
register float startingFloat;
register double scaled;
register double converted;
register long copy;
register double oldSetting;
{
union
{
double d;
int i[2];
}setting;
register double newSetting;
asm volatile ( "mffs %0" : "=f" ( oldSetting ) );
setting.d = oldSetting;
setting.i[1] &= 0xFFFFFFFC;
newSetting = setting.d;
asm volatile( "mtfsf 7, %0" : : "f" (newSetting ) );
}
if( count >= 6 )
{
startingFloat = (src++)[0];
scaled = startingFloat * scale;
startingFloat = (src++)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale;
startingFloat = (src++)[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale;
startingFloat = (src++)[0];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale;
startingFloat = (src++)[0];
copy = buffer[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale;
startingFloat = (src++)[0];
count -= 6;
loopCount = count / 2;
count &= 1;
while( loopCount-- )
{
register float startingFloat2;
register double scaled2;
register double converted2;
register long copy2;
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) );
copy2 = buffer[1];
__asm__ __volatile__ ( "fmuls %0, %1, %2" : "=f" (scaled2) : "f" ( startingFloat), "f" (scale) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted), "b%" (sizeof(*buffer)), "r" (buffer) : "memory" );
startingFloat2 = (src)[0]; src+=2;
dst+=2;
__asm__ __volatile__ ( "stwbrx %0, %1, %2" : : "r" (copy2), "r" (-sizeof(dst[0])), "r" (dst) );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) );
copy = buffer[0];
__asm__ __volatile__ ( "fmuls %0, %1, %2" : "=f" (scaled) : "f" ( startingFloat2), "f" (scale) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted2), "b%" (0), "r" (buffer) : "memory" );
startingFloat = (src)[-1];
}
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = buffer[1];
__stfiwx( converted, sizeof(float), buffer );
converted = __fctiw( scaled );
scaled = startingFloat * scale;
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = buffer[0];
__stfiwx( converted, 0, buffer );
converted = __fctiw( scaled );
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = buffer[1];
__stfiwx( converted, sizeof(float), buffer );
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = buffer[0];
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
copy = buffer[1];
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) ); dst++;
}
while( count-- )
{
double scaled = src[0] * scale;
double converted = __fctiw( scaled );
__stfiwx( converted, 0, buffer );
copy = buffer[0];
__asm__ __volatile__ ( "stwbrx %0, 0, %1" : : "r" (copy), "r" (dst) );
src++;
dst++;
}
__asm__ __volatile__ ( "mtfsf 7, %0" : : "f" (oldSetting) );
}
void Float32ToNativeInt32( float *src, signed long *dst, unsigned int count )
{
register double scale = 2147483648.0;
unsigned long loopCount;
register float startingFloat;
register double scaled;
register double converted;
register double oldSetting;
{
union
{
double d;
int i[2];
}setting;
register double newSetting;
asm volatile ( "mffs %0" : "=f" ( oldSetting ) );
setting.d = oldSetting;
setting.i[1] &= 0xFFFFFFFC;
newSetting = setting.d;
asm volatile( "mtfsf 7, %0" : : "f" (newSetting ) );
}
if( count >= 3 )
{
startingFloat = (src++)[0];
scaled = startingFloat * scale;
startingFloat = (src++)[0];
converted = __fctiw( scaled );
scaled = startingFloat * scale;
startingFloat = (src++)[0];
count -= 3;
loopCount = count / 2;
count &= 1;
while( loopCount-- )
{
register float startingFloat2;
register double scaled2;
register double converted2;
startingFloat2 = (src)[0];
__asm__ __volatile__ ( "fmul %0, %1, %2" : "=f" (scaled2) : "f" ( startingFloat), "f" (scale) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted), "b%" (0), "r" (dst) : "memory" );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted2) : "f" ( scaled ) );
startingFloat = (src)[1]; src+=2;
__asm__ __volatile__ ( "fmul %0, %1, %2" : "=f" (scaled) : "f" ( startingFloat2), "f" (scale) );
__asm__ __volatile__ ( "stfiwx %0, %1, %2" : : "f" (converted2), "b%" (4), "r" (dst) : "memory" );
__asm__ __volatile__ ( "fctiw %0, %1" : "=f" (converted) : "f" ( scaled2 ) );
dst+=2;
}
__stfiwx( converted, 0, dst++ );
converted = __fctiw( scaled );
__asm__ __volatile__ ( "fmul %0, %1, %2" : "=f" (scaled) : "f" ( startingFloat), "f" (scale) );
__stfiwx( converted, 0, dst++ );
converted = __fctiw( scaled );
__stfiwx( converted, 0, dst++ );
}
while( count-- )
{
double scaled = src[0] * scale;
double converted = __fctiw( scaled );
__stfiwx( converted, 0, dst );
dst++;
src++;
}
asm volatile( "mtfsf 7, %0" : : "f" (oldSetting) );
}
#endif
Generated by GNU enscript 1.6.4.