X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Flpcm.h;h=b6598c93a3cd9682ad13ef200b6fe3e1130ae04e;hb=a7e00a42195bd01fad75e5800fcbadeb1a5d3efd;hp=ae67a43fb6798a5f8e4becef295c65f54251dd4d;hpb=48e2f01c5653c8f643b2a763e1cfa2efc1eccd60;p=fdkaac.git diff --git a/src/lpcm.h b/src/lpcm.h index ae67a43..b6598c9 100644 --- a/src/lpcm.h +++ b/src/lpcm.h @@ -31,7 +31,34 @@ typedef struct pcm_sample_description_t { #define PCM_BYTES_PER_CHANNEL(desc) \ ((desc)->bytes_per_frame / (desc)->channels_per_frame) -int pcm_convert_to_native_sint16(const pcm_sample_description_t *format, - const void *input, uint32_t nframes, - int16_t **result, uint32_t *osize); +#if defined(_MSC_VER) && _MSC_VER < 1800 +# ifdef _M_IX86 +static inline int lrint(double x) +{ + int n; + _asm { + fld x + fistp n + } + return n; +} +# else +# include +static inline int lrint(double x) +{ + return _mm_cvtsd_si32(_mm_load_sd(&x)); +} +# endif +#endif + +static +inline double pcm_clip(double n, double min_value, double max_value) +{ + if (n < min_value) + return min_value; + else if (n > max_value) + return max_value; + return n; +} + #endif