[FFmpeg-devel] [PATCH] Fix warnings about int64 to int32 conversion

Don Moir donmoir at comcast.net
Wed May 16 08:15:28 CEST 2012


----- Original Message ----- 
From: "Michael Bradshaw" <mbradshaw at sorensonmedia.com>
To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>
Sent: Tuesday, May 15, 2012 7:07 PM
Subject: [FFmpeg-devel] [PATCH] Fix warnings about int64 to int32 conversion


> Attached patch fixes the following two warnings about converting from
> int64 to int32:
>
> 1>ffmpeg_latest\include\libavutil\common.h(174) : warning C4244:
> 'return' : conversion from 'int64_t' to 'int32_t', possible loss of
> data
> 1>ffmpeg_latest\include\libavutil\common.h(233) : warning C4244:
> 'argument' : conversion from 'uint64_t' to 'uint32_t', possible loss
> of data
>

Yeah thanks, these have been annoying from the start. common.h is included 
wih the primary header files.

Here is one more along the same thing in libavutil/rational.h

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 if(a.num && b.num) return (int)((a.num>>31) - (b.num>>31));
    else                    return INT_MIN;
}

I don't think there will be any more warnings when using the primary header 
files after these changes. At least these are the only warnings I see 
currently. 



More information about the ffmpeg-devel mailing list