[FFmpeg-devel] [PATCH] lavu/rational: add syntactic sugar.

Michael Niedermayer michaelni at gmx.at
Tue Dec 31 18:43:28 CET 2013


On Tue, Dec 31, 2013 at 05:24:21PM +0100, Nicolas George wrote:
> Add a function to create a rational
> and macros for common values.
> 
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavutil/rational.h |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/libavutil/rational.h b/libavutil/rational.h
> index b9800ee..363d18c 100644
> --- a/libavutil/rational.h
> +++ b/libavutil/rational.h
> @@ -46,6 +46,22 @@ typedef struct AVRational{
>  } AVRational;
>  
>  /**
> + * Create a rational.
> + * Useful for compilers that do not support compound literals.
> + * @note  The return value is not reduced.
> + */
> +static inline AVRational av_make_q(int num, int den)
> +{
> +    AVRational r = { num, den };
> +    return r;
> +}
> +

> +#define AV_ZERO_Q         (av_make_q(0, 1))
> +#define AV_ONE_Q          (av_make_q(1, 1))
> +#define AV_UNDEF_Q        (av_make_q(1, 0))
> +#define AV_INVALID_Q      (av_make_q(0, 0))

i dont like these defines, they hide the actual values and can make
it harder to understand code
(of course not for us here now as we see the defines first but a
 reader who reads a mix of av_make_q() and AV_*_Q has to look 2+
  things up instead of one)

we also dont use
#define FIVE 5
#define ONE 1

and such

but av_make_q(), is a brilliant idea IMHO


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

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131231/deeccc43/attachment.asc>


More information about the ffmpeg-devel mailing list