Commit 498e1c6b authored by Michael Niedermayer's avatar Michael Niedermayer

lavu: check av_clip*() limits

This code cannot use av_assert* due to circular header dependancies
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ddeb2992
...@@ -97,6 +97,9 @@ av_const int av_log2_16bit(unsigned v); ...@@ -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) 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; if (a < amin) return amin;
else if (a > amax) return amax; else if (a > amax) return amax;
else return a; else return a;
...@@ -111,6 +114,9 @@ static av_always_inline av_const int av_clip_c(int a, int amin, int amax) ...@@ -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) 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; if (a < amin) return amin;
else if (a > amax) return amax; else if (a > amax) return amax;
else return a; else return a;
...@@ -216,6 +222,9 @@ static av_always_inline int av_sat_dadd32_c(int a, int b) ...@@ -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) 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; if (a < amin) return amin;
else if (a > amax) return amax; else if (a > amax) return amax;
else return a; else return a;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment