[MPlayer-dev-eng] [PATCH 6/9] libavutil: Optimize clipping routines for avr32
Hans-Christian Egtvedt
hans-christian.egtvedt at atmel.com
Mon Feb 16 17:16:55 CET 2009
Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt at atmel.com>
---
libavutil/common.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/libavutil/common.h b/libavutil/common.h
index d8f2f64..f976156 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -162,23 +162,39 @@ static inline av_const int av_log2_16bit(unsigned int v)
* @param amax maximum value of the clip range
* @return clipped value
*/
+#if defined(ARCH_AVR32)
+#define av_clip(a, amin, amax) \
+ ({ int __tmp__; \
+ asm ("min\t%0, %1, %2\n" \
+ "max\t%0, %0, %3\n" \
+ : "=&r"(__tmp__) : "r"(a), "r"(amax), "r"(amin)); \
+ __tmp__; })
+#else
static inline av_const int av_clip(int a, int amin, int amax)
{
if (a < amin) return amin;
else if (a > amax) return amax;
else return a;
}
+#endif
/**
* Clips a signed integer value into the 0-255 range.
* @param a value to clip
* @return clipped value
*/
+#if defined(ARCH_AVR32)
+#define av_clip_uint8(a) \
+ ({ int __tmp__ = a; \
+ asm ("satu\t%0 >> 0, 8" : "+r"(__tmp__)); \
+ __tmp__; })
+#else
static inline av_const uint8_t av_clip_uint8(int a)
{
if (a&(~255)) return (-a)>>31;
else return a;
}
+#endif
/**
* Clips a signed integer value into the -32768,32767 range.
--
1.5.6.3
More information about the MPlayer-dev-eng
mailing list