[FFmpeg-cvslog] libavutil: cast truncated values to uint32_t

Alfred E. Heggestad git at videolan.org
Tue Aug 27 14:47:40 CEST 2013


ffmpeg | branch: master | Alfred E. Heggestad <aeh at db.org> | Mon Aug 26 22:31:43 2013 +0200| [16c3ed5837884e2b60cf40e762be6c58b13d7ba6] | committer: Michael Niedermayer

libavutil: cast truncated values to uint32_t

programs using ffmpeg that are compiled with -Wshorten-64-to-32
gives a warning when using header files common.h and rational.h

cast 64-bit truncated values to (uint32_t) to avoid the warning

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavutil/common.h   |    4 ++--
 libavutil/rational.h |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index c7c32fd..9f0f998 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -175,7 +175,7 @@ static av_always_inline av_const int16_t av_clip_int16_c(int a)
  */
 static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
 {
-    if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
+    if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);
     else                                         return (int32_t)a;
 }
 
@@ -279,7 +279,7 @@ static av_always_inline av_const int av_popcount_c(uint32_t x)
  */
 static av_always_inline av_const int av_popcount64_c(uint64_t x)
 {
-    return av_popcount((uint32_t)x) + av_popcount(x >> 32);
+    return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x >> 32));
 }
 
 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
diff --git a/libavutil/rational.h b/libavutil/rational.h
index 417e29e..b9800ee 100644
--- a/libavutil/rational.h
+++ b/libavutil/rational.h
@@ -55,7 +55,7 @@ typedef struct AVRational{
 static inline int av_cmp_q(AVRational a, AVRational b){
     const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
 
-    if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1;
+    if(tmp) return (int)((tmp ^ a.den ^ b.den)>>63)|1;
     else if(b.den && a.den) return 0;
     else if(a.num && b.num) return (a.num>>31) - (b.num>>31);
     else                    return INT_MIN;



More information about the ffmpeg-cvslog mailing list