[FFmpeg-devel] [PATCH 2/3] x86: asm for sign/zero_extend()

Mans Rullgard mans
Sun Feb 21 01:35:58 CET 2010


---
 libavcodec/x86/mathops.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
index 010cfb7..0c17f35 100644
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -97,4 +97,22 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
     return a;
 }
 
+#define sign_extend sign_extend
+static inline int sign_extend(int val, unsigned bits)
+{
+    __asm__ ("shll %1, %0 \n\t"
+             "sarl %1, %0 \n\t"
+             : "+&r" (val) : "ic" ((uint8_t)-bits));
+    return val;
+}
+
+#define zero_extend zero_extend
+static inline unsigned zero_extend(unsigned val, unsigned bits)
+{
+    __asm__ ("shll %1, %0 \n\t"
+             "shrl %1, %0 \n\t"
+             : "+&r" (val) : "ic" ((uint8_t)-bits));
+    return val;
+}
+
 #endif /* AVCODEC_X86_MATHOPS_H */
-- 
1.7.0




More information about the ffmpeg-devel mailing list