[vlc-devel] [PATCH 1/3] vlc_common.h: add helpers to get the upper rounded value of integer divisions
Steve Lhomme
robux4 at gmail.com
Fri Mar 17 09:37:53 CET 2017
On Fri, Mar 17, 2017 at 9:36 AM, Steve Lhomme <robux4 at videolabs.io> wrote:
> ---
> include/vlc_common.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/vlc_common.h b/include/vlc_common.h
> index 6a75753dbf..b72dbfe689 100644
> --- a/include/vlc_common.h
> +++ b/include/vlc_common.h
> @@ -507,6 +507,11 @@ struct vlc_common_members
> /* clip v in [min, max] */
> #define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max))
>
> +/* upper rounded value of the integer division */
> +#define VLC_UPPER_DIV(v, div) (((v) + (div) - 1) / (div))
> +/* upper modulo value of the integer */
> +#define VLC_UPPER_MODULO(v, mod) (VLC_UPPER_DIV(v, mod) * mod)
Maybe (v + (v % mod)) is more efficient but for now I kept the same
algorithm found in some parts of the code.
> +
> VLC_USED
> static inline int64_t GCD ( int64_t a, int64_t b )
> {
> --
> 2.11.1
>
More information about the vlc-devel
mailing list