[FFmpeg-devel] [PATCH 1/3] common: add ff_parity()
James Almer
jamrial at gmail.com
Sun Jan 3 21:54:34 CET 2016
On 1/3/2016 4:22 PM, Clément Bœsch wrote:
> On Sun, Jan 03, 2016 at 08:21:00PM +0100, Clément Bœsch wrote:
> [...]
>> +static av_always_inline av_const int ff_parity(uint32_t v)
>> +{
>> +#if HAVE_PARITY
>> + return __builtin_parity(v);
>> +#else
>> + return av_popcount(v) & 1;
>
> doing a popcount being overkill, this could be replaced with
> (0x6996966996696996ULL >> (x & 63) ^ (x>>7) ^ (x>>6)) & 1
Are you sure that's correct for an uint32_t?
>
> Whatever people prefers
No need for the configure check. Make the above the c generic version (Add it to
common.h or intmath.h), then on x86/intmath.h make it use __builtin_parity if
__GNU__ is true.
Even if the popcnt instruction is not supported by the target cpu, the code
generated for __builtin_parity by GCC is much better than the one generated by
av_popcount_c()
More information about the ffmpeg-devel
mailing list