diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2010-04-21 17:57:48 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2010-04-21 17:57:48 +0000 |
commit | b1078e9fe6b5d8f034d15a6ab91430fd41921fe2 (patch) | |
tree | 5d16af4805e9567267f3f3daa96e015523f4216c /libavcodec/audioconvert.c | |
parent | 6858ce2ffc4c57a279b22ab6d8eb56ac3884796e (diff) | |
download | ffmpeg-b1078e9fe6b5d8f034d15a6ab91430fd41921fe2.tar.gz |
Move clipping of audio samples (for those codecs outputting float) from decoder
to the audio conversion routines.
Originally committed as revision 22937 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/audioconvert.c')
-rw-r--r-- | libavcodec/audioconvert.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c index 8ea7158ce4..a38d87351f 100644 --- a/libavcodec/audioconvert.c +++ b/libavcodec/audioconvert.c @@ -209,7 +209,7 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\ } //FIXME put things below under ifdefs so we do not waste space for cases no codec will need -//FIXME rounding and clipping ? +//FIXME rounding ? CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 , *(const uint8_t*)pi) else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8) @@ -226,14 +226,14 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\ else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32, *(const int32_t*)pi) else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31))) else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31))) - else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<7)) + 0x80) - else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<15))) - else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<31))) + else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, av_clip_uint8( lrintf(*(const float*)pi * (1<<7)) + 0x80)) + else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, av_clip_int16( lrintf(*(const float*)pi * (1<<15)))) + else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float*)pi * (1U<<31)))) else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_FLT, *(const float*)pi) else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(const float*)pi) - else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<7)) + 0x80) - else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<15))) - else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<31))) + else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, av_clip_uint8( lrint(*(const double*)pi * (1<<7)) + 0x80)) + else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, av_clip_int16( lrint(*(const double*)pi * (1<<15)))) + else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double*)pi * (1U<<31)))) else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_DBL, *(const double*)pi) else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(const double*)pi) else return -1; |