diff options
author | wm4 <wm4@nowhere> | 2019-06-16 18:22:45 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | 56f09fa03da99cc34620c9d3569a3d06e5c95c11 (patch) | |
tree | b98737a8c87f923cbe031d31538f6ab29f609eeb /common/common.h | |
parent | 4291329d563c12dedca4b911accb7cae077225da (diff) | |
download | mpv-56f09fa03da99cc34620c9d3569a3d06e5c95c11.tar.bz2 mpv-56f09fa03da99cc34620c9d3569a3d06e5c95c11.tar.xz |
common: add macro for checking whether a value is a power of two
I think I repeated this inline in some places (or maybe not), and some
experimental but discarded code used it. Add it anyway, maybe it'll be
useful. Or it'll give someone a chance to get a contribution into mpv by
removing an unused macro.
Diffstat (limited to 'common/common.h')
-rw-r--r-- | common/common.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/common/common.h b/common/common.h index f5392fc575..16e1ec4cfd 100644 --- a/common/common.h +++ b/common/common.h @@ -44,6 +44,7 @@ #define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1)) #define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1)) #define MP_IS_ALIGNED(x, align) (!((x) & ((align) - 1))) +#define MP_IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1))) // Return "a", or if that is NOPTS, return "def". #define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a)) |