mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-12-26 15:44:51 +01:00
Tremor can be used instead of Vorbis. Usefull for ARM based machines
This commit is contained in:
parent
ebb70977ea
commit
205d71eccc
|
@ -312,7 +312,7 @@ inline FLOAT NormByteToFloat( const ULONG ul)
|
|||
// fast float to int conversion
|
||||
inline SLONG FloatToInt( FLOAT f)
|
||||
{
|
||||
#if (defined USE_PORTABLE_C)
|
||||
#if defined(__arm__) || defined(USE_PORTABLE_C)
|
||||
return((SLONG) (f + 0.5f)); /* best of luck to you. */
|
||||
|
||||
#elif (defined __MSVC_INLINE__)
|
||||
|
@ -340,7 +340,7 @@ inline SLONG FloatToInt( FLOAT f)
|
|||
|
||||
// log base 2 of any float numero
|
||||
inline FLOAT Log2( FLOAT f) {
|
||||
#if (defined USE_PORTABLE_C)
|
||||
#if (defined USE_PORTABLE_C) || defined(__arm__)
|
||||
// !!! FIXME: What's wrong with log2()?
|
||||
return (FLOAT)(log10(f)*3.321928094887); // log10(x)/log10(2)
|
||||
|
||||
|
@ -377,12 +377,12 @@ inline SLONG FastLog2( SLONG x)
|
|||
{
|
||||
#if (defined USE_PORTABLE_C)
|
||||
register SLONG val = x;
|
||||
register SLONG retval = 0;
|
||||
while (retval < 32)
|
||||
register SLONG retval = 31;
|
||||
while (retval > 0)
|
||||
{
|
||||
if (val & (1 << retval))
|
||||
return retval;
|
||||
retval++;
|
||||
retval--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -497,31 +497,50 @@ ENGINE_API FLOAT Sin(ANGLE a);
|
|||
ENGINE_API FLOAT Cos(ANGLE a);
|
||||
ENGINE_API FLOAT Tan(ANGLE a);
|
||||
|
||||
#ifdef __arm__
|
||||
inline ENGINE_API FLOAT SinFast(ANGLE a) { return sinf(a*(PI/ANGLE_180)); };
|
||||
inline ENGINE_API FLOAT CosFast(ANGLE a) { return cosf(a*(PI/ANGLE_180)); };
|
||||
inline ENGINE_API FLOAT TanFast(ANGLE a) { return tanf(a*(PI/ANGLE_180)); };
|
||||
inline ANGLE ASin(FLOAT y) {
|
||||
return AngleRad (asinf(Clamp(y, -1.0f, 1.0f)));
|
||||
}
|
||||
inline ANGLE ACos(FLOAT x) {
|
||||
return AngleRad (acosf(Clamp(x, -1.0f, 1.0f)));
|
||||
|
||||
}
|
||||
inline ANGLE ATan(FLOAT z) {
|
||||
return AngleRad (atanf(z));
|
||||
}
|
||||
inline ANGLE ATan2(FLOAT y, FLOAT x) {
|
||||
return AngleRad (atan2f(y, x));
|
||||
}
|
||||
#else
|
||||
inline ENGINE_API FLOAT SinFast(ANGLE a) { return (FLOAT)sin(a*(PI/ANGLE_180)); };
|
||||
inline ENGINE_API FLOAT CosFast(ANGLE a) { return (FLOAT)cos(a*(PI/ANGLE_180)); };
|
||||
inline ENGINE_API FLOAT TanFast(ANGLE a) { return (FLOAT)tan(a*(PI/ANGLE_180)); };
|
||||
|
||||
inline ANGLE ASin(FLOAT y) {
|
||||
return AngleRad (asin(Clamp(y, -1.0f, 1.0f)));
|
||||
}
|
||||
inline ANGLE ASin(DOUBLE y) {
|
||||
return AngleRad (asin(Clamp(y, -1.0, 1.0)));
|
||||
}
|
||||
inline ANGLE ACos(FLOAT x) {
|
||||
return AngleRad (acos(Clamp(x, -1.0f, 1.0f)));
|
||||
}
|
||||
inline ANGLE ACos(DOUBLE x) {
|
||||
return AngleRad (acos(Clamp(x, -1.0, 1.0)));
|
||||
}
|
||||
inline ANGLE ATan(FLOAT z) {
|
||||
return AngleRad (atan(z));
|
||||
}
|
||||
inline ANGLE ATan(DOUBLE z) {
|
||||
return AngleRad (atan(z));
|
||||
}
|
||||
inline ANGLE ATan2(FLOAT y, FLOAT x) {
|
||||
return AngleRad (atan2(y, x));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline ANGLE ASin(DOUBLE y) {
|
||||
return AngleRad (asin(Clamp(y, -1.0, 1.0)));
|
||||
}
|
||||
inline ANGLE ACos(DOUBLE x) {
|
||||
return AngleRad (acos(Clamp(x, -1.0, 1.0)));
|
||||
}
|
||||
inline ANGLE ATan(DOUBLE z) {
|
||||
return AngleRad (atan(z));
|
||||
}
|
||||
inline ANGLE ATan2(DOUBLE y, DOUBLE x) {
|
||||
return AngleRad (atan2(y, x));
|
||||
}
|
||||
|
|
|
@ -96,7 +96,11 @@ public:
|
|||
|
||||
|
||||
// ------------------------------------ Ogg Vorbis
|
||||
#ifdef USE_TREMOR
|
||||
#include <tremor/ivorbisfile.h> // we define needed stuff ourselves, and ignore the rest
|
||||
#else
|
||||
#include <vorbis/vorbisfile.h> // we define needed stuff ourselves, and ignore the rest
|
||||
#endif
|
||||
|
||||
// vorbis vars
|
||||
BOOL _bOVEnabled = FALSE;
|
||||
|
@ -208,7 +212,11 @@ void CSoundDecoder::InitPlugins(void)
|
|||
#if ((defined PLATFORM_WIN32) && (defined NDEBUG))
|
||||
#define VORBISLIB "vorbisfile_d"
|
||||
#else
|
||||
#define VORBISLIB "vorbisfile"
|
||||
#ifdef USE_TREMOR
|
||||
#define VORBISLIB "vorbisidec"
|
||||
#else
|
||||
#define VORBISLIB "vorbisfile"
|
||||
#endif
|
||||
#endif
|
||||
_hOV = CDynamicLoader::GetInstance(VORBISLIB);
|
||||
if( _hOV->GetError() != NULL) {
|
||||
|
@ -571,8 +579,12 @@ INDEX CSoundDecoder::Decode(void *pvDestBuffer, INDEX ctBytesToDecode)
|
|||
char *pch = (char *)pvDestBuffer;
|
||||
INDEX ctDecoded = 0;
|
||||
while (ctDecoded<ctBytesToDecode) {
|
||||
#ifdef USE_TREMOR
|
||||
long iRes = pov_read(sdc_pogg->ogg_vfVorbisFile, pch, ctBytesToDecode-ctDecoded, &iCurrrentSection);
|
||||
#else
|
||||
long iRes = pov_read(sdc_pogg->ogg_vfVorbisFile, pch, ctBytesToDecode-ctDecoded,
|
||||
0, 2, 1, &iCurrrentSection);
|
||||
#endif
|
||||
if (iRes<=0) {
|
||||
return ctDecoded;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user