#512(avutil:new): libavutil\common.h conversion warnings
#512: libavutil\common.h conversion warnings ---------------------------------------+--------------------------------- Reporter: DonMoir | Owner: michael Type: enhancement | Status: new Priority: minor | Component: avutil Version: unspecified | Keywords: Blocked By: | Blocking: Reproduced by developer: 0 | Analyzed by developer: 0 ---------------------------------------+--------------------------------- 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. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/512> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#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
#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 | -------------------------------------+----------------------------------- Comment (by DonMoir): 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. -- Ticket URL: <https://avcodec.org/trac/ffmpeg/ticket/512#comment:2> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#512: libavutil\common.h conversion warnings -------------------------------------+----------------------------------- Reporter: DonMoir | Owner: michael Type: enhancement | Status: closed Priority: minor | Component: avutil Version: unspecified | Resolution: wontfix Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+----------------------------------- Changes (by cehoyos): * status: new => closed * resolution: => wontfix Comment: 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.) -- Ticket URL: <https://avcodec.org/trac/ffmpeg/ticket/512#comment:3> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#512: libavutil\common.h conversion warnings -------------------------------------+----------------------------------- Reporter: DonMoir | Owner: michael Type: enhancement | Status: closed Priority: minor | Component: avutil Version: unspecified | Resolution: wontfix Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+----------------------------------- Comment (by DonMoir): fixed -- Ticket URL: <https://trac.ffmpeg.org/ticket/512#comment:4> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg