On 9/14/2017 6:07 AM, Diego Biurrun wrote:
> On Mon, Aug 28, 2017 at 12:53:09PM -0300, James Almer wrote:
>> On 8/28/2017 12:08 PM, wm4 wrote:
>>> On Mon, 28 Aug 2017 11:52:52 -0300
>>> James Almer <jamr...@gmail.com> wrote:
>>>> --- a/libavutil/cpu.c
>>>> +++ b/libavutil/cpu.c
>>>> @@ -184,12 +185,20 @@ int av_cpu_count(void)
>>>>  
>>>>  size_t av_cpu_max_align(void)
>>>>  {
>>>> -    int flags = av_get_cpu_flags();
>>>> +    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_ALTIVEC | AV_CPU_FLAG_SSE | 
>>>> AV_CPU_FLAG_NEON))
>>>> +    if (flags & AV_CPU_FLAG_SSE)
>>>>          return 16;
>>>> +#endif
>>>>  
>>>>      return 8;
>>>>  }
>>
>> Something like
>>
>> size_t av_cpu_max_align(void)
>> {
>>     if (ARCH_AARCH64)
>>         return ff_get_cpu_max_align_aarch64();
>>     if (ARCH_ARM)
>>         return ff_get_cpu_max_align_arm();
>>     if (ARCH_PPC)
>>         return ff_get_cpu_max_align_ppc();
>>     if (ARCH_X86)
>>         return ff_get_cpu_max_align_x86();
>>     return 8;
>> }
>>
>> Would be more in line with the rest of the codebase, but seems overkill
>> to me. I can send such an implementation anyway if that's preferred in
>> any case.
> 
> That would be much better. Your original patch is IMO a step in the wrong
> direction. Arch-specific code should not litter the C code in the first
> place and your patch produces an ifdef maze on top of that.

There's a precedent in av_parse_cpu_flags(), which is why
av_cpu_max_align() was written this way i presume. But in any case sure,
I'll split it across arch folders.

> 
> Diego
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to