libavutil: add av_mod_uintp2

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2015-03-18 15:08:45 -03:00
parent 2a8198b32f
commit d13e521cc8
1 changed files with 14 additions and 0 deletions

View File

@ -210,6 +210,17 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
else return a;
}
/**
* Clear high bits from an unsigned integer starting with specific bit position
* @param a value to clip
* @param p bit position to clip at
* @return clipped value
*/
static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
{
return a & ((1 << p) - 1);
}
/**
* Add two signed 32-bit values with saturation.
*
@ -466,6 +477,9 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
#ifndef av_clip_uintp2
# define av_clip_uintp2 av_clip_uintp2_c
#endif
#ifndef av_mod_uintp2
# define av_mod_uintp2 av_mod_uintp2_c
#endif
#ifndef av_sat_add32
# define av_sat_add32 av_sat_add32_c
#endif