[FFmpeg-devel] [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c()
Tomas Härdin
git at haerdin.se
Thu May 30 12:48:08 EEST 2024
tor 2024-05-30 klockan 00:31 +0200 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > */
> > static av_always_inline av_const int32_t av_clipl_int32_c(int64_t
> > a)
> > {
> > - if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return
> > (int32_t)((a>>63) ^ 0x7FFFFFFF);
> > - else return
> > (int32_t)a;
> > + if ((a+UINT64_C(0x80000000)) & ~UINT64_C(0xFFFFFFFF)) return
> > (int32_t)((a>>63) ^ 0x7FFFFFFF);
> > + else return
> > (int32_t)a;
>
> IMO (uint64_t)a + 0x80000000 is more readable. (Maybe it would even
> be
> good to use >> 32 instead of ~UINT64_C(0xFFFFFFFF)?)
It already uses UINT64_C, hence why I used it.
>> 32 would work also. Does it make any difference performance wise?
/Tomas
More information about the ffmpeg-devel
mailing list