[FFmpeg-devel] [PATCH 1/3] common: add ff_parity()
James Almer
jamrial at gmail.com
Sun Jan 3 22:55:34 CET 2016
On 1/3/2016 6:33 PM, Clément Bœsch wrote:
> On Sun, Jan 03, 2016 at 05:54:34PM -0300, James Almer wrote:
>> 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?
>>
>
> Erm. Yeah no, my bad.
>
>>>
>>> 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.
>
> Why should we use __builtin_parity only on x86?
Yeah, my bad. Was thinking as if this was about __builtin_popcount, which is awful
with GCC for anything except a few x86 targets.
More information about the ffmpeg-devel
mailing list