]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add av_clipf() function to common.h and use it in ra288.c
authorvitor <vitor@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 13 Jul 2008 19:59:44 +0000 (19:59 +0000)
committervitor <vitor@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 13 Jul 2008 19:59:44 +0000 (19:59 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14213 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/ra288.c
libavutil/common.h

index 72ed8102ee250203c62b746a8ca99e65e1660680..57ee6c20dd5bca629cbcb0add7880dbdbae1835c 100644 (file)
@@ -88,14 +88,8 @@ static void decode(Real288_internal *glob, float gain, int cb_coef)
 
     /* output */
     for (x=0; x < 5; x++) {
-        float f = glob->sb[4-x] + buffer[x];
-
-        if (f > 4095)
-            f = 4095;
-        else if (f < -4095)
-            f = -4095;
-
-        glob->output[glob->phase*5+x] = glob->sb[4-x] = f;
+        glob->output[glob->phase*5+x] = glob->sb[4-x] =
+            av_clipf(glob->sb[4-x] + buffer[x], -4095, 4095);
     }
 }
 
index 5a56832eebc3057f6fb4c369eacbadf6cb80b7e4..696b03e78b80d6d75ab840455a43d67441851e6f 100644 (file)
@@ -225,6 +225,20 @@ static inline av_const int16_t av_clip_int16(int a)
     else                    return a;
 }
 
+/**
+ * clip a float value into the amin-amax range
+ * @param a value to clip
+ * @param amin minimum value of the clip range
+ * @param amax maximum value of the clip range
+ * @return clipped value
+ */
+static inline av_const float av_clipf(float a, float amin, float amax)
+{
+    if      (a < amin) return amin;
+    else if (a > amax) return amax;
+    else               return a;
+}
+
 /* math */
 int64_t av_const ff_gcd(int64_t a, int64_t b);