Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#512 closed enhancement (wontfix)

libavutil\common.h conversion warnings

Reported by: DonMoir Owned by: Michael Niedermayer
Priority: minor Component: avutil
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

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.

Change History (4)

comment:1 by Carl Eugen Hoyos, 10 years ago

Description: modified (diff)

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

comment:2 by DonMoir, 10 years ago

I am using MS Visual Studio 2005 Version 8.

The warning looks like this:

c:\ffmpeg-dev\include\libavutil\rational.h(53) : warning C4244: 'return' : conversion from 'const int64_t' to 'int', possible loss of data

And I will consider sending patches. Bear with me, I am just getting up to speed on all this.

comment:3 by Carl Eugen Hoyos, 10 years ago

Resolution: wontfix
Status: newclosed

I believe it is very unlikely that this gets changed, but please do not hesitate to send a patch to ffmpeg-devel for a proper discussion.
(But consider disabling warning C4244, if you call a clip function, you usually really do consider possible loss of data.)

comment:4 by DonMoir, 8 years ago


Note: See TracTickets for help on using tickets.