aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-21 22:53:06 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-04 22:19:31 +0100
commit498e1c6bb963eb7e611ba72a9c2ecad9b306e6b0 (patch)
treed5bd8dc9e3e48229f89cb91e688206e662cf0c44
parentddeb299234cc555ad3997d76f7c7dfaf0bb17a02 (diff)
downloadffmpeg-498e1c6bb963eb7e611ba72a9c2ecad9b306e6b0.tar.gz
lavu: check av_clip*() limits
This code cannot use av_assert* due to circular header dependancies Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavutil/common.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index 0f36309fa9..3adb1f0c06 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -97,6 +97,9 @@ av_const int av_log2_16bit(unsigned v);
*/
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
{
+#if defined(HAVE_AV_CONFIG_H) && ASSERT_LEVEL >= 2
+ if (amin > amax) abort();
+#endif
if (a < amin) return amin;
else if (a > amax) return amax;
else return a;
@@ -111,6 +114,9 @@ static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
*/
static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
{
+#if defined(HAVE_AV_CONFIG_H) && ASSERT_LEVEL >= 2
+ if (amin > amax) abort();
+#endif
if (a < amin) return amin;
else if (a > amax) return amax;
else return a;
@@ -216,6 +222,9 @@ static av_always_inline int av_sat_dadd32_c(int a, int b)
*/
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
{
+#if defined(HAVE_AV_CONFIG_H) && ASSERT_LEVEL >= 2
+ if (amin > amax) abort();
+#endif
if (a < amin) return amin;
else if (a > amax) return amax;
else return a;