diff options
author | James Almer <jamrial@gmail.com> | 2017-02-22 12:53:34 -0500 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-03-01 11:23:19 -0500 |
commit | 19d57ca62e7134cb3cd5e937443501c417ceb79a (patch) | |
tree | 7c33abb77b0debad05508be2929713c3ca98a80e | |
parent | 7bfda7d157eb6f7a2df908addd60221a7a6f5eb0 (diff) | |
download | ffmpeg-19d57ca62e7134cb3cd5e937443501c417ceb79a.tar.gz |
libavutil: add av_mod_uintp2
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavutil/common.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h index d2ddcba9ed..3832f107ba 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -183,6 +183,17 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) } /** + * 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. * * @param a one value @@ -410,6 +421,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 |