12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #ifndef _V_SCALES_H_
- #define _V_SCALES_H_
- #include <math.h>
- #include "os.h"
- #ifdef _MSC_VER
- #define inline __inline
- #endif
- #define VORBIS_IEEE_FLOAT32 1
- #ifdef VORBIS_IEEE_FLOAT32
- static inline float unitnorm(float x){
- union {
- ogg_uint32_t i;
- float f;
- } ix;
- ix.f = x;
- ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
- return ix.f;
- }
- static inline float todB(const float *x){
- union {
- ogg_uint32_t i;
- float f;
- } ix;
- ix.f = *x;
- ix.i = ix.i&0x7fffffff;
- return (float)(ix.i * 7.17711438e-7f -764.6161886f);
- }
- #define todB_nn(x) todB(x)
- #else
- static float unitnorm(float x){
- if(x<0)return(-1.f);
- return(1.f);
- }
- #define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
- #define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
- #endif
- #define fromdB(x) (exp((x)*.11512925f))
- #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
- #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
- #define toMEL(n) (log(1.f+(n)*.001f)*1442.695f)
- #define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f)
- #define toOC(n) (log(n)*1.442695f-5.965784f)
- #define fromOC(o) (exp(((o)+5.965784f)*.693147f))
- #endif
|