[FFmpeg-cvslog] lavc: add ff_u8_to_s8() for safe type punning of uint8_t to int8_t

Justin Ruggles git at videolan.org
Thu Sep 19 11:54:05 CEST 2013


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Sep 16 10:11:32 2013 -0400| [9ae53c5860e17d087642d27b00dade071970a2e7] | committer: Justin Ruggles

lavc: add ff_u8_to_s8() for safe type punning of uint8_t to int8_t

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ae53c5860e17d087642d27b00dade071970a2e7
---

 libavcodec/mathops.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 8a2ce90..6c216c2 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -224,4 +224,14 @@ static inline av_const unsigned int ff_sqrt(unsigned int a)
     return b - (a < b * b);
 }
 
+static inline int8_t ff_u8_to_s8(uint8_t a)
+{
+    union {
+        uint8_t u8;
+        int8_t  s8;
+    } b;
+    b.u8 = a;
+    return b.s8;
+}
+
 #endif /* AVCODEC_MATHOPS_H */



More information about the ffmpeg-cvslog mailing list