[FFmpeg-cvslog] r14213 - in trunk: libavcodec/ra288.c libavutil/common.h

vitor subversion
Sun Jul 13 21:59:44 CEST 2008


Author: vitor
Date: Sun Jul 13 21:59:44 2008
New Revision: 14213

Log:
Add av_clipf() function to common.h and use it in ra288.c

Modified:
   trunk/libavcodec/ra288.c
   trunk/libavutil/common.h

Modified: trunk/libavcodec/ra288.c
==============================================================================
--- trunk/libavcodec/ra288.c	(original)
+++ trunk/libavcodec/ra288.c	Sun Jul 13 21:59:44 2008
@@ -88,14 +88,8 @@ static void decode(Real288_internal *glo
 
     /* 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);
     }
 }
 

Modified: trunk/libavutil/common.h
==============================================================================
--- trunk/libavutil/common.h	(original)
+++ trunk/libavutil/common.h	Sun Jul 13 21:59:44 2008
@@ -225,6 +225,20 @@ static inline av_const int16_t av_clip_i
     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);
 




More information about the ffmpeg-cvslog mailing list