[FFmpeg-devel] [PATCH] lavu: add av_clipd_c
Paul B Mahol
onemda at gmail.com
Thu Apr 18 15:45:10 CEST 2013
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavutil/common.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libavutil/common.h b/libavutil/common.h
index beaf9f7..e303c25 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -229,6 +229,23 @@ static av_always_inline av_const float av_clipf_c(float a, float amin, float ama
else return a;
}
+/**
+ * Clip a double 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 av_always_inline av_const double av_clipd_c(double a, double amin, double amax)
+{
+#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
+ if (amin > amax) abort();
+#endif
+ if (a < amin) return amin;
+ else if (a > amax) return amax;
+ else return a;
+}
+
/** Compute ceil(log2(x)).
* @param x value used to compute ceil(log2(x))
* @return computed ceiling of log2(x)
@@ -428,6 +445,9 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
#ifndef av_clipf
# define av_clipf av_clipf_c
#endif
+#ifndef av_clipd
+# define av_clipd av_clipd_c
+#endif
#ifndef av_popcount
# define av_popcount av_popcount_c
#endif
--
1.7.11.2
More information about the ffmpeg-devel
mailing list