[FFmpeg-trac] #512(avutil:new): libavutil\common.h conversion warnings

FFmpeg trac at avcodec.org
Tue Sep 27 10:10:35 CEST 2011


#512: libavutil\common.h conversion warnings
-------------------------------------+-----------------------------------
             Reporter:  DonMoir      |                    Owner:  michael
                 Type:  enhancement  |                   Status:  new
             Priority:  minor        |                Component:  avutil
              Version:  unspecified  |               Resolution:
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-----------------------------------

Old description:

> Would you please make a couple minor changes to libavutil\common.h.
>
> static av_always_inline av_const int16_t av_clip_int16_c(int a)
> {
>     if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
>     else                      return a;
> }
>
> the returns cause me a conversion warning because they need to be cast to
> int16_t and so I have to change this each time I get a new include for
> ffmpeg.
>
> change to:
>
> static av_always_inline av_const int16_t av_clip_int16_c(int a)
> {
>     if ((a+0x8000) & ~0xFFFF) return (int16_t)((a>>31) ^ 0x7FFF);
>     else                      return (int16_t)a;
> }
>
> cast return values to (int32_t) for the following:
>
> 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;
>     else                                         return a;
> }
>
> also for this one in libavutil\rational.h cast return values to (int):
>
> 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 (int)(((tmp ^ a.den ^ b.den)>>63)|1);
>     else if(b.den && a.den) return 0;
>     else if(a.num && b.num) return (int)((a.num>>31) - (b.num>>31));
>     else                    return INT_MIN;
> }
>
> There is no other case I have come across the produces any warnings but
> these.

New description:

 Would you please make a couple minor changes to libavutil\common.h.


 {{{
 static av_always_inline av_const int16_t av_clip_int16_c(int a)
 {
     if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
     else                      return a;
 }
 }}}

 the returns cause me a conversion warning because they need to be cast to
 int16_t and so I have to change this each time I get a new include for
 ffmpeg.

 change to:


 {{{
 static av_always_inline av_const int16_t av_clip_int16_c(int a)
 {
     if ((a+0x8000) & ~0xFFFF) return (int16_t)((a>>31) ^ 0x7FFF);
     else                      return (int16_t)a;
 }
 }}}

 cast return values to (int32_t) for the following:


 {{{
 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;
     else                                         return a;
 }
 }}}

 also for this one in libavutil\rational.h cast return values to (int):


 {{{
 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 (int)(((tmp ^ a.den ^ b.den)>>63)|1);
     else if(b.den && a.den) return 0;
     else if(a.num && b.num) return (int)((a.num>>31) - (b.num>>31));
     else                    return INT_MIN;
 }
 }}}


 There is no other case I have come across the produces any warnings but
 these.

--

Comment (by cehoyos):

 This is missing a few things (apart from "Code block" which I tried to
 add):
 Which compiler are you using?
 How do the warnings look like?

 And please consider sending patches made with "git diff >patchfile.diff"
 to ffmpeg-devel

-- 
Ticket URL: <https://avcodec.org/trac/ffmpeg/ticket/512#comment:1>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list