diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index f022e852f45697214c6754377e4e76c7b7d1f9f9..327787a5b9bbe1a4e0b7e146955af9d3e7fe7a8c 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -50,12 +50,6 @@
 
 #define BLKSIZE 1024
 
-#define CLAMP_TO_SHORT(value) \
-if (value > 32767) \
-    value = 32767; \
-else if (value < -32768) \
-    value = -32768; \
-
 /* step_table[] and index_table[] are from the ADPCM reference source */
 /* This is the index table: */
 static const int index_table[16] = {
@@ -215,7 +209,7 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho
     int delta = sample - c->prev_sample;
     int nibble = FFMIN(7, abs(delta)*4/step_table[c->step_index]) + (delta<0)*8;
     c->prev_sample = c->prev_sample + ((step_table[c->step_index] * yamaha_difflookup[nibble]) / 8);
-    CLAMP_TO_SHORT(c->prev_sample);
+    c->prev_sample = av_clip_int16(c->prev_sample);
     c->step_index = av_clip(c->step_index + index_table[nibble], 0, 88);
     return nibble;
 }
@@ -234,7 +228,7 @@ static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, shor
     nibble= av_clip(nibble, -8, 7)&0x0F;
 
     predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
-    CLAMP_TO_SHORT(predictor);
+    predictor = av_clip_int16(predictor);
 
     c->sample2 = c->sample1;
     c->sample1 = predictor;
@@ -259,7 +253,7 @@ static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c,
     nibble = FFMIN(7, abs(delta)*4/c->step) + (delta<0)*8;
 
     c->predictor = c->predictor + ((c->step * yamaha_difflookup[nibble]) / 8);
-    CLAMP_TO_SHORT(c->predictor);
+    c->predictor = av_clip_int16(c->predictor);
     c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
     c->step = av_clip(c->step, 127, 24567);
 
@@ -339,7 +333,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
 #define STORE_NODE(NAME, STEP_INDEX)\
                     int d;\
                     uint32_t ssd;\
-                    CLAMP_TO_SHORT(dec_sample);\
+                    dec_sample = av_clip_int16(dec_sample);\
                     d = sample - dec_sample;\
                     ssd = nodes[j]->ssd + d*d;\
                     if(nodes_next[frontier-1] && ssd >= nodes_next[frontier-1]->ssd)\
@@ -676,7 +670,7 @@ static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble,
     if (sign) predictor -= diff;
     else predictor += diff;
 
-    CLAMP_TO_SHORT(predictor);
+    predictor = av_clip_int16(predictor);
     c->predictor = predictor;
     c->step_index = step_index;
 
@@ -689,7 +683,7 @@ static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble)
 
     predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
     predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
-    CLAMP_TO_SHORT(predictor);
+    predictor = av_clip_int16(predictor);
 
     c->sample2 = c->sample1;
     c->sample1 = predictor;
@@ -725,7 +719,7 @@ static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
     if(c->step > 32767)
         c->step = 32767;
 
-    CLAMP_TO_SHORT(predictor);
+    predictor = av_clip_int16(predictor);
     c->predictor = predictor;
     return (short)predictor;
 }
@@ -766,7 +760,7 @@ static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned c
     }
 
     c->predictor += (c->step * yamaha_difflookup[nibble]) / 8;
-    CLAMP_TO_SHORT(c->predictor);
+    c->predictor = av_clip_int16(c->predictor);
     c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
     c->step = av_clip(c->step, 127, 24567);
     return c->predictor;
@@ -795,7 +789,7 @@ static void xa_decode(short *out, const unsigned char *in,
 
             t = (signed char)(d<<4)>>4;
             s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
-            CLAMP_TO_SHORT(s);
+            s = av_clip_int16(s);
             *out = s;
             out += inc;
             s_2 = s_1;
@@ -821,7 +815,7 @@ static void xa_decode(short *out, const unsigned char *in,
 
             t = (signed char)d >> 4;
             s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
-            CLAMP_TO_SHORT(s);
+            s = av_clip_int16(s);
             *out = s;
             out += inc;
             s_2 = s_1;
@@ -915,7 +909,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         if(cs->predictor & 0x8000)
             cs->predictor -= 0x10000;
 
-        CLAMP_TO_SHORT(cs->predictor);
+        cs->predictor = av_clip_int16(cs->predictor);
 
         cs->step_index = (*src++) & 0x7F;
 
@@ -1187,8 +1181,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
                 next_right_sample = (next_right_sample +
                     (current_right_sample * coeff1r) +
                     (previous_right_sample * coeff2r) + 0x80) >> 8;
-                CLAMP_TO_SHORT(next_left_sample);
-                CLAMP_TO_SHORT(next_right_sample);
+                next_left_sample = av_clip_int16(next_left_sample);
+                next_right_sample = av_clip_int16(next_right_sample);
 
                 previous_left_sample = current_left_sample;
                 current_left_sample = next_left_sample;
@@ -1318,7 +1312,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
                     c->status[i].step_index += table[delta & (~signmask)];
 
                     c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
-                    c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767);
+                    c->status[i].predictor = av_clip_int16(c->status[i].predictor);
 
                     *samples++ = c->status[i].predictor;
                     if (samples >= samples_end) {
@@ -1392,7 +1386,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
 
                     sampledat = ((prev[ch][0]*factor1
                                 + prev[ch][1]*factor2) >> 11) + (sampledat>>exp);
-                    CLAMP_TO_SHORT(sampledat);
+                    sampledat = av_clip_int16(sampledat);
                     *samples = sampledat;
                     prev[ch][1] = prev[ch][0];
                     prev[ch][0] = *samples++;
diff --git a/libavcodec/adx.c b/libavcodec/adx.c
index 4ea8929bc10f58381a0e2b6757d42f662e1cb91e..7185a32ce08f8b4afd2df6aad1699a82f54f9e7c 100644
--- a/libavcodec/adx.c
+++ b/libavcodec/adx.c
@@ -46,8 +46,6 @@ typedef struct {
 #define    SCALE1    0x7298
 #define    SCALE2    0x3350
 
-#define    CLIP(s)    if (s>32767) s=32767; else if (s<-32768) s=-32768
-
 /* 18 bytes <-> 32 samples */
 
 #ifdef CONFIG_ENCODERS
@@ -110,7 +108,7 @@ static void adx_decode(short *out,const unsigned char *in,PREV *prev)
         // d>>=4; if (d&8) d-=16;
         d = ((signed char)d >> 4);
         s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
-        CLIP(s0);
+        s0 = av_clip_int16(s0);
         *out++=s0;
         s2 = s1;
         s1 = s0;
@@ -119,7 +117,7 @@ static void adx_decode(short *out,const unsigned char *in,PREV *prev)
         //d&=15; if (d&8) d-=16;
         d = ((signed char)(d<<4) >> 4);
         s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
-        CLIP(s0);
+        s0 = av_clip_int16(s0);
         *out++=s0;
         s2 = s1;
         s1 = s0;
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 0b1400712b459ddd0206b0f490567fe2cc6fb0f3..e7239a3bab465d736948cbae5269ca58bb037f2f 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -895,13 +895,13 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
     if (q->channels == 1) {
         /* mono */
         for (i = 0; i<1024; i++)
-            samples[i] = av_clip(round(q->outSamples[i]), -32768, 32767);
+            samples[i] = av_clip_int16(round(q->outSamples[i]));
         *data_size = 1024 * sizeof(int16_t);
     } else {
         /* stereo */
         for (i = 0; i < 1024; i++) {
-            samples[i*2] = av_clip(round(q->outSamples[i]), -32768, 32767);
-            samples[i*2+1] = av_clip(round(q->outSamples[1024+i]), -32768, 32767);
+            samples[i*2] = av_clip_int16(round(q->outSamples[i]));
+            samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i]));
         }
         *data_size = 2048 * sizeof(int16_t);
     }
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 2765b12eb69bccf48efe81df84551b1517644972..43b661d18657954e296003b81fd0c97da8995f3b 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -906,7 +906,7 @@ saturate_output_float (COOKContext *q, int chan, int16_t *out)
      */
     for (j = 0; j < q->samples_per_channel; j++) {
         out[chan + q->nb_channels * j] =
-          av_clip(lrintf(output[j]), -32768, 32767);
+          av_clip_int16(lrintf(output[j]));
     }
 }
 
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index 6243881deed55d61780ef61a6a3262b14d7ec390..0ce05c821acd19a3c962be4b2590d979e58ec036 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -46,8 +46,6 @@ typedef struct DPCMContext {
     const int *sol_table;//for SOL_DPCM
 } DPCMContext;
 
-#define SATURATE_S16(x)  if (x < -32768) x = -32768; \
-  else if (x > 32767) x = 32767;
 #define SE_16BIT(x)  if (x & 0x8000) x -= 0x10000;
 
 static int interplay_delta_table[] = {
@@ -190,7 +188,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
         /* decode the samples */
         for (in = 8, out = 0; in < buf_size; in++, out++) {
             predictor[channel_number] += s->roq_square_array[buf[in]];
-            SATURATE_S16(predictor[channel_number]);
+            predictor[channel_number] = av_clip_int16(predictor[channel_number]);
             output_samples[out] = predictor[channel_number];
 
             /* toggle channel */
@@ -213,7 +211,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
 
         while (in < buf_size) {
             predictor[channel_number] += interplay_delta_table[buf[in++]];
-            SATURATE_S16(predictor[channel_number]);
+            predictor[channel_number] = av_clip_int16(predictor[channel_number]);
             output_samples[out++] = predictor[channel_number];
 
             /* toggle channel */
@@ -248,7 +246,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
             diff >>= shift[channel_number];
             predictor[channel_number] += diff;
 
-            SATURATE_S16(predictor[channel_number]);
+            predictor[channel_number] = av_clip_int16(predictor[channel_number]);
             output_samples[out++] = predictor[channel_number];
 
             /* toggle channel */
@@ -277,7 +275,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
                 n = buf[in++];
                 if (n & 0x80) s->sample[channel_number] -= s->sol_table[n & 0x7F];
                 else s->sample[channel_number] += s->sol_table[n & 0x7F];
-                SATURATE_S16(s->sample[channel_number]);
+                s->sample[channel_number] = av_clip_int16(s->sample[channel_number]);
                 output_samples[out++] = s->sample[channel_number];
                 /* toggle channel */
                 channel_number ^= s->channels - 1;
diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c
index 78cdbe93a9a0186797936bb8e94e9a905e7bd856..ecaa94e4d0f383f1678447315d20b0597f50920b 100644
--- a/libavcodec/dsicinav.c
+++ b/libavcodec/dsicinav.c
@@ -325,7 +325,7 @@ static int cinaudio_decode_frame(AVCodecContext *avctx,
     }
     while (buf_size > 0) {
         cin->delta += cinaudio_delta16_table[*src++];
-        cin->delta = av_clip(cin->delta, -32768, 32767);
+        cin->delta = av_clip_int16(cin->delta);
         *samples++ = cin->delta;
         --buf_size;
     }
diff --git a/libavcodec/liba52.c b/libavcodec/liba52.c
index 1fbed09d883bbc6544f621f1d94f0808eabb6873..ce0f822d932a9f73ad84e9f922a10f3cf8f5c912 100644
--- a/libavcodec/liba52.c
+++ b/libavcodec/liba52.c
@@ -123,11 +123,7 @@ static int a52_decode_init(AVCodecContext *avctx)
 /**** the following two functions comes from a52dec */
 static inline int blah (int32_t i)
 {
-    if (i > 0x43c07fff)
-        return 32767;
-    else if (i < 0x43bf8000)
-        return -32768;
-    return i - 0x43c00000;
+    return av_clip_int16(i - 0x43c00000);
 }
 
 static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index 5d40e91b525447fb267e8169870703eb62ac95a3..faaceb0ba7621d6ffbb039405873d6feafd7b808 100644
--- a/libavcodec/libvorbis.c
+++ b/libavcodec/libvorbis.c
@@ -307,8 +307,7 @@ static inline int conv(int samples, float **pcm, char *buf, int channels) {
 
             val = mono[j] * 32767.f;
 
-            if(val > 32767) val = 32767 ;
-            if(val < -32768) val = -32768 ;
+            val = av_clip_int16(val);
 
             *ptr = val ;
             ptr += channels;
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 3c4b757d6ad207fc268dff18dc2c1c5c79ea9479..d679b006be73969928d3c31acf13a82756314872 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -822,10 +822,7 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
 #if FRAC_BITS <= 15
         /* NOTE: can cause a loss in precision if very high amplitude
            sound */
-        if (v > 32767)
-            v = 32767;
-        else if (v < -32768)
-            v = -32768;
+        v = av_clip_int16(v);
 #endif
         synth_buf[j] = v;
     }
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
index c4f4b813b337e87724d5181f4657299ef130e1e7..c820c732baa6915d413ead601a19d2aa82efe230 100644
--- a/libavcodec/ra144.c
+++ b/libavcodec/ra144.c
@@ -486,9 +486,7 @@ static int ra144_decode_frame(AVCodecContext * avctx,
     shptr=glob->output_buffer;
     while (shptr<glob->output_buffer+BLOCKSIZE) {
       s=*(shptr++)<<2;
-      *data=s;
-      if (s>32767) *data=32767;
-      if (s<-32767) *data=-32768;
+      *data=av_clip_int16(s);
       data++;
     }
     b+=30;
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
index ffd6fc71c637475cd7e73f888901198968091e83..da1443d98f900ab505470b91e7021edb026cd008 100644
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -279,7 +279,7 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
         }
 
 #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
-        dst[dst_index] = av_clip(lrintf(val), -32768, 32767);
+        dst[dst_index] = av_clip_int16(lrintf(val));
 #else
         val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
         dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index f3388589b6bc5e0f36caea47c0abfb17fb6a3789..bff21eb8d2cc2aeae10adf5905c5bdb1a6ff35b1 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -926,14 +926,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
 
     // internal -> short
     for (i = 0; i < s->frame_size; i++)
-    {
-        if (s->int_samples[i] > 32767)
-            samples[i] = 32767;
-        else if (s->int_samples[i] < -32768)
-            samples[i] = -32768;
-        else
-            samples[i] = s->int_samples[i];
-    }
+        samples[i] = av_clip_int16(s->int_samples[i]);
 
     align_get_bits(&gb);
 
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index c37e8fd48b69abc4c9871046229a47b7626c33b0..9507666cd47067b1960dafea7cbb7a60c321e158 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -458,7 +458,7 @@ static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data,
             s->predictors[chan] -= vmdaudio_table[buf[i] & 0x7F];
         else
             s->predictors[chan] += vmdaudio_table[buf[i]];
-        s->predictors[chan] = av_clip(s->predictors[chan], -32768, 32767);
+        s->predictors[chan] = av_clip_int16(s->predictors[chan]);
         out[i] = s->predictors[chan];
         chan ^= stereo;
     }
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index f828c789c7378e27ca63a162cffb21039fd8d08b..01bd47f8e15266ae622cba9de89ae7a96b017c55 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -740,10 +740,7 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
 
         for(i=0;i<n;i++) {
             a = lrintf(*iptr++);
-            if (a > 32767)
-                a = 32767;
-            else if (a < -32768)
-                a = -32768;
+            a = av_clip_int16(a);
             *ptr = a;
             ptr += incr;
         }