common: add MP_IS_ALIGNED macro

This commit is contained in:
wm4 2019-06-07 13:33:47 +02:00
parent 7c356ee836
commit 46247df6e5
1 changed files with 1 additions and 0 deletions

View File

@ -43,6 +43,7 @@
// align must be a power of two (align >= 1), x >= 0
#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)))
// Return "a", or if that is NOPTS, return "def".
#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))