On Wed, Sep 25, 2019 at 12:02:56AM +0200, Andreas Rheinhardt wrote:
> Left shifting a negative integer is undefined, yet often needed.
> Therefore add a macro that internally uses multiplication by powers of
> two to make it clear that a shift is intended.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com>
> ---
> I don't insist on this macro. I only added it so that one can easily see
> that shifting was intended. I initially wanted to use "FFLS", but
> eventually chose FFLSHIFT because it is self-explanatory.
> 
>  libavutil/common.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavutil/common.h b/libavutil/common.h
> index af35397eb9..93c5dd0af7 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -60,6 +60,14 @@
>  /* Backwards compat. */
>  #define FF_CEIL_RSHIFT AV_CEIL_RSHIFT
>  
> +/**
> + * Left shift macro designed to tackle the undefinedness
> + * of left-shifting negative numbers.
> + *
> + * Note: Still undefined if the multiplication overflows.
> + */
> +#define FFLSHIFT(a,b) ((a) * (1 << (b)))

with 
a * (1 << b)
everyone knows what it does even if one doesnt know why its done that way

with 
FFLSHIFT(a, b)
only people who looked up the macro know what it does and why.

so iam a bit sceptic that this is a good idea.

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to