[FFmpeg-cvslog] lavc/libutvideoenc: Cast an unsigned constant to int.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri May 13 19:28:04 CEST 2016

On 13.05.2016, at 10:51, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:

> Reimar Döffinger <Reimar.Doeffinger <at> gmx.de> writes:
>> On 13.05.2016, at 02:49, Carl Eugen Hoyos <cehoyos <at> ag.or.at> wrote:
>>> Reimar Döffinger <Reimar.Doeffinger <at> gmx.de> writes:
>>>> That doesn't seem like a good idea, AV_CODEC_CAP_LOSSLESS does 
>>>> not fit in int,
>>> Why does 0x8000 not fit in int?
>> Isn't it 0x80000000??
> You are right but this still is <= 32bit, no?

To my knowledge there is no guarantee that (int)0x80000000u == 0x80000000u
So there is no guarantee that this code works at all.

>> Either way, the compiler said it didn't fit...
> I believe the compiler said it cannot convert a large positive 
> (32bit) value into (signed) int.

The reason for that would still be that it doesn't fit.

>>>> so we should not try to store it in one, not explicitly cast 
>>>> to int...
>>> What is the correct fix?
>> Where does the "int" the compiler complains about come from?
> I believe it comes from line 3552 of avcodec.h:
>    int capabilities;
>> I guess it should be "unsigned" or a 64 bit type instead.
> It was unsigned but the compiler doesn't like the conversion 
> from unsigned to int and 64 bit are not an option afaict.

Where does it get converted from unsigned to int?
If we want valid code, we can never ever convert anything that contains AV_CODEC_CAP_LOSSLESS to int.

More information about the ffmpeg-cvslog mailing list