mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-30 11:24:17 +00:00
Merge commit 'bf07d813f6c88b5a76980f321cf7272d799c4216'
* commit 'bf07d813f6c88b5a76980f321cf7272d799c4216': libavutil: Add av_clip_intp2 Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
88d850ecb3
@ -184,6 +184,20 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
else return (int32_t)a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer into the -(2^p),(2^p-1) range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
||||
{
|
||||
if ((a + (1 << p)) & ~((1 << (p + 1)) - 1))
|
||||
return (a >> 31) ^ ((1 << p) - 1);
|
||||
else
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer to an unsigned power of two range.
|
||||
* @param a value to clip
|
||||
@ -446,6 +460,9 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
||||
#ifndef av_clipl_int32
|
||||
# define av_clipl_int32 av_clipl_int32_c
|
||||
#endif
|
||||
#ifndef av_clip_intp2
|
||||
# define av_clip_intp2 av_clip_intp2_c
|
||||
#endif
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user