[FFmpeg-devel] [PATCH] avcodec/h264_mb: Fix undefined shifts

Christophe Gisquet christophe.gisquet at gmail.com
Thu Mar 12 17:02:10 CET 2015


2015-03-12 16:17 GMT+01:00 Michael Niedermayer <michaelni at gmx.at>:
> i belive any motion vector that points left outside the picture will
> trigger this one

OK I thought it was a magnitude issue, it's actually mvx being
negative. That's indeed mighty weird and didn't know about this.

> the compiler should optimize the extra operation out, ive
> confirmed this before posting the patch in some cases but i didnt
> check all

Funny that it actually restores the original operation. I really
wonder what architecture would have this undefined (excluding overflow

>> If we are going to overengineer such issues, we could have something like:
>> # define LEGAL_SHIFT(a, b, type) ( (a) * (((type)1) << (b) )
>> #else
>> # define LEGAL_SHIFT(a, b, type) ( (a) << (b) )
>> #endif
> that could be done it would make the code less readable though

Let's not do this, it seems that's what the compiler already does,
so... But I'd be curious to know what theorical compilers and/or
theorical archictures are affected.


More information about the ffmpeg-devel mailing list