diff options
author | James Almer <jamrial@gmail.com> | 2017-09-27 22:56:53 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-09-27 23:03:57 -0300 |
commit | 522f87708653af3badcdc33be983bcc6009de49b (patch) | |
tree | 40b863b9f71e5f0eff288377c300e02988427f8c /libavutil/cpu.c | |
parent | 5256a86da067a324ece20bb9584880f5a63744ce (diff) | |
parent | e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e (diff) | |
download | ffmpeg-522f87708653af3badcdc33be983bcc6009de49b.tar.gz |
Merge commit 'e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e'
* commit 'e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e':
cpu: add a function for querying maximum required data alignment
Adapted to work with the arbitrary runtime cpuflag changes av_force_cpu_flags()
can generate.
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil/cpu.c')
-rw-r--r-- | libavutil/cpu.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c index a22da0fa8c..ab04494acf 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -16,9 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <stddef.h> #include <stdint.h> #include <stdatomic.h> +#include "attributes.h" #include "cpu.h" #include "cpu_internal.h" #include "config.h" @@ -299,3 +301,40 @@ int av_cpu_count(void) return nb_cpus; } + +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 | + AV_CPU_FLAG_VSX | + AV_CPU_FLAG_POWER8)) + return 16; +#elif ARCH_X86 + if (flags & (AV_CPU_FLAG_AVX2 | + AV_CPU_FLAG_AVX | + AV_CPU_FLAG_XOP | + AV_CPU_FLAG_FMA4 | + AV_CPU_FLAG_FMA3 | + AV_CPU_FLAG_AVXSLOW)) + return 32; + if (flags & (AV_CPU_FLAG_AESNI | + AV_CPU_FLAG_SSE42 | + AV_CPU_FLAG_SSE4 | + AV_CPU_FLAG_SSSE3 | + AV_CPU_FLAG_SSE3 | + AV_CPU_FLAG_SSE2 | + AV_CPU_FLAG_SSE | + AV_CPU_FLAG_ATOM | + AV_CPU_FLAG_SSSE3SLOW | + AV_CPU_FLAG_SSE3SLOW | + AV_CPU_FLAG_SSE2SLOW)) + return 16; +#endif + + return 8; +} |