aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2013-09-16 10:11:32 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2013-09-18 14:10:05 -0400
commit9ae53c5860e17d087642d27b00dade071970a2e7 (patch)
tree66fd6a1fe897728ea1a363730ca1fcda2554846e /libavcodec
parent5626f994f273af80fb100d4743b963304de9e05c (diff)
downloadffmpeg-9ae53c5860e17d087642d27b00dade071970a2e7.tar.gz
lavc: add ff_u8_to_s8() for safe type punning of uint8_t to int8_t
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mathops.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 8a2ce90d6a..6c216c25dc 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 */