[FFmpeg-devel] [PATCH] cpu: add a function for querying maximum required data alignment

James Almer jamrial at gmail.com
Sat Sep 2 22:00:17 EEST 2017


On 9/2/2017 3:48 PM, Hendrik Leppkes wrote:
> On Sat, Sep 2, 2017 at 8:29 PM, Clément Bœsch <u at pkh.me> wrote:
>> On Sat, Sep 02, 2017 at 02:07:01PM -0300, James Almer wrote:
>> [...]
>>> +size_t av_cpu_max_align(void)
>>> +{
>>> +    int av_unused flags = av_get_cpu_flags();
>>> +
>>> +#if ARCH_ARM || ARCH_AARCH64
>>> +    if (flags & AV_CPU_FLAG_NEON)
>>> +        return 16;
>>> +#elif ARCH_PPC
>>> +    if (flags & AV_CPU_FLAG_ALTIVEC)
>>> +        return 16;
>>
>>> +#elif ARCH_X86
>>> +    if (flags & AV_CPU_FLAG_AVX)
>>> +        return 32;
>>> +    if (flags & AV_CPU_FLAG_SSE)
>>> +        return 16;
>>> +#endif
>>
>> mmh, will this really work in FFmpeg? I think we have a difference related
>> to the flags dependency. Typically, if having SSE2 doesn't imply you have
>> SSE. I think you may want to extend the mask.
>>
>>
> 
> If we do, we should really get rid of supporting that. Its really not
> very meaningful to select say SSSE3 but not SSE2. SSSE3 flagged
> functions are still going to use the majority of SSE2 instructions,
> and so on.

av_parse_cpu_caps() + av_force_cpu_flags() was added precisely to enable
single flags without pulling "dependencies" and the doxy even recommends
their usage over av_parse_cpu_flags() + av_set_cpu_flags_mask().

I don't know if it's really useful or not, but forcing CPU flags is a
developer functionality, in any case. In pretty much any real world case
people will call av_get_cpu_flags() and use the default return value for
the host machine, not bothering to disable anything and much less force
flags that are not present.

> If you unselect MMX, I would wager a bunch of checks all over fall
> over and fail on you. :p

MMX is forcefully enabled if anything newer than that is also enabled.
It's the only exception to the above precisely because things break if
we don't :p

> 
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 



More information about the ffmpeg-devel mailing list