diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2007-05-09 23:08:01 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2007-05-09 23:08:01 +0000 |
commit | 7d5aaa049cfdf3d0ab805c6dda722e4710f3adac (patch) | |
tree | 01ff627bebb6fd4e73719080235808932772950a /libavcodec/pcm.c | |
parent | 13dec85765f8c1b57d152e691f51ec86152b0e4a (diff) | |
download | ffmpeg-7d5aaa049cfdf3d0ab805c6dda722e4710f3adac.tar.gz |
Factorize usum
Originally committed as revision 8960 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r-- | libavcodec/pcm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 5570c01bd1..693e14b925 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -169,12 +169,13 @@ static int pcm_encode_close(AVCodecContext *avctx) */ static inline void encode_from16(int bps, int le, int us, short **samples, uint8_t **dst, int n) { + int usum = us ? 0x8000 : 0; if (bps > 2) memset(*dst, 0, n * bps); if (le) *dst += bps - 2; for(;n>0;n--) { register int v = *(*samples)++; - if (us) v += 0x8000; + v += usum; (*dst)[le] = v >> 8; (*dst)[1 - le] = v; *dst += bps; @@ -361,10 +362,11 @@ static int pcm_decode_init(AVCodecContext * avctx) static inline void decode_to16(int bps, int le, int us, uint8_t **src, short **samples, int src_len) { + int usum = us ? -0x8000 : 0; register int n = src_len / bps; if (le) *src += bps - 2; for(;n>0;n--) { - *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) - (us?0x8000:0); + *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) + usum; *src += bps; } if (le) *src -= bps - 2; |