X-Git-Url: http://git.ieval.ro/?p=fdkaac.git;a=blobdiff_plain;f=src%2Flpcm.h;h=2ac93abf0cadb0bfdc893e7604fa908355bf163a;hp=8e896ae07dbacf3838963cf1ad35ad2801cd4c19;hb=4d48b091d49818772a47559ba7fd7ab58fdd7682;hpb=d11b0441317d05811b30490b778d1051bafb2570 diff --git a/src/lpcm.h b/src/lpcm.h index 8e896ae..2ac93ab 100644 --- a/src/lpcm.h +++ b/src/lpcm.h @@ -31,6 +31,36 @@ typedef struct pcm_sample_description_t { #define PCM_BYTES_PER_CHANNEL(desc) \ ((desc)->bytes_per_frame / (desc)->channels_per_frame) +#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; +} + int pcm_convert_to_native_sint16(const pcm_sample_description_t *format, const void *input, uint32_t nframes, int16_t *result);