Re: [FFmpeg-devel] [PATCH 1/2] libavutil: add av_zhb
On 17.03.2015, at 05:08, James Almer jamr...@gmail.com wrote: Signed-off-by: James Almer jamr...@gmail.com --- Better name (av_zero_high_bits?) and doxygen welcome. Maybe av_wrap_intp2? (to align with clip function naming) Or av_mod_p2? Essentially it does a modulo with a power of 2. Otherwise clear high bits seems a more natural name than zero. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] libavutil: add av_zhb
On 17/03/15 5:28 AM, Reimar Döffinger wrote: On 17.03.2015, at 05:08, James Almer jamr...@gmail.com wrote: Signed-off-by: James Almer jamr...@gmail.com --- Better name (av_zero_high_bits?) and doxygen welcome. Maybe av_wrap_intp2? (to align with clip function naming) Or av_mod_p2? Essentially it does a modulo with a power of 2. Otherwise clear high bits seems a more natural name than zero. Well, the bmi2 instruction uses zero http://www.felixcloutier.com/x86/BZHI.html Nonetheless, i like av_mod_p2 more than av_zhb, so unless someone else suggests something else I'll resend the set using that name. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] libavutil: add av_zhb
Signed-off-by: James Almer jamr...@gmail.com --- Better name (av_zero_high_bits?) and doxygen welcome. libavutil/common.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavutil/common.h b/libavutil/common.h index 852c1de..2ee5a98 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -301,6 +301,17 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x) return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x 32)); } +/** + * Zero high bits from a starting from bit position p + * @param a value to clip + * @param p bit position to clip at + * @return clipped value + */ +static av_always_inline av_const unsigned av_zhb_c(unsigned a, unsigned p) +{ +return a ((1 p) - 1); +} + #define MKTAG(a,b,c,d) ((a) | ((b) 8) | ((c) 16) | ((unsigned)(d) 24)) #define MKBETAG(a,b,c,d) ((d) | ((c) 8) | ((b) 16) | ((unsigned)(a) 24)) @@ -484,3 +495,6 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x) #ifndef av_popcount64 # define av_popcount64av_popcount64_c #endif +#ifndef av_zhb +# define av_zhb av_zhb_c +#endif -- 2.3.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel