diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-08-11 23:29:21 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-08-11 23:29:21 +0000 |
commit | 88e2d5882be9c5a103090c113676950c3c25125b (patch) | |
tree | be51702b4c95b91b263f2e6f73c2534dab0f37ee /libavcodec/adpcm.c | |
parent | e4a50e6d2e4798f7dec9f9224605dd09b55c18d7 (diff) | |
download | ffmpeg-88e2d5882be9c5a103090c113676950c3c25125b.tar.gz |
more usage of av_clip()
Originally committed as revision 10082 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r-- | libavcodec/adpcm.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 53341fd17f..dad0d72331 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -706,11 +706,7 @@ static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble) c->predictor = av_clip_int16(c->predictor); /* calculate new step and clamp it to range 511..32767 */ new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8; - c->step = new_step; - if(c->step < 511) - c->step = 511; - if(c->step > 32767) - c->step = 32767; + c->step = av_clip(new_step, 511, 32767); return (short)c->predictor; } @@ -723,16 +719,8 @@ static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble delta = nibble & ((1<<(size-1))-1); diff = delta << (7 + c->step + shift); - if (sign) - c->predictor -= diff; - else - c->predictor += diff; - /* clamp result */ - if (c->predictor > 16256) - c->predictor = 16256; - else if (c->predictor < -16384) - c->predictor = -16384; + c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256); /* calculate new step */ if (delta >= (2*size - 3) && c->step < 3) |