[FFmpeg-cvslog] cpu: split flag checks per arch in av_cpu_max_align()

James Almer git at videolan.org
Sat Nov 11 20:57:52 EET 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Sep 14 16:51:26 2017 -0300| [3d828c9fd51aa8c348ff11241e212e5834b4f806] | committer: Luca Barbato

cpu: split flag checks per arch in av_cpu_max_align()

Signed-off-by: James Almer <jamrial at gmail.com>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d828c9fd51aa8c348ff11241e212e5834b4f806
---

 libavutil/aarch64/cpu.c  |  9 +++++++++
 libavutil/arm/cpu.c      |  9 +++++++++
 libavutil/cpu.c          | 15 ++++++++-------
 libavutil/cpu_internal.h |  5 +++++
 libavutil/ppc/cpu.c      |  9 +++++++++
 libavutil/x86/cpu.c      | 11 +++++++++++
 6 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
index 37a7d8defa..4718218255 100644
--- a/libavutil/aarch64/cpu.c
+++ b/libavutil/aarch64/cpu.c
@@ -26,3 +26,12 @@ int ff_get_cpu_flags_aarch64(void)
            AV_CPU_FLAG_NEON  * HAVE_NEON  |
            AV_CPU_FLAG_VFP   * HAVE_VFP;
 }
+
+size_t ff_get_cpu_max_align_aarch64(void)
+{
+    int flags = av_get_cpu_flags();
+
+    if (flags & AV_CPU_FLAG_NEON)
+        return 16;
+    return 8;
+}
diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
index 2effb72610..a29adf2761 100644
--- a/libavutil/arm/cpu.c
+++ b/libavutil/arm/cpu.c
@@ -151,3 +151,12 @@ int ff_get_cpu_flags_arm(void)
 }
 
 #endif
+
+size_t ff_get_cpu_max_align_arm(void)
+{
+    int flags = av_get_cpu_flags();
+
+    if (flags & AV_CPU_FLAG_NEON)
+        return 16;
+    return 8;
+}
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 5aef6af217..fa76fecfc6 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -184,12 +184,13 @@ int av_cpu_count(void)
 
 size_t av_cpu_max_align(void)
 {
-    int flags = av_get_cpu_flags();
-
-    if (flags & AV_CPU_FLAG_AVX)
-        return 32;
-    if (flags & (AV_CPU_FLAG_ALTIVEC | AV_CPU_FLAG_SSE | AV_CPU_FLAG_NEON))
-        return 16;
-
+    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;
 }
diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index 49c7b070e4..18c744a983 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -41,4 +41,9 @@ int ff_get_cpu_flags_arm(void);
 int ff_get_cpu_flags_ppc(void);
 int ff_get_cpu_flags_x86(void);
 
+size_t ff_get_cpu_max_align_aarch64(void);
+size_t ff_get_cpu_max_align_arm(void);
+size_t ff_get_cpu_max_align_ppc(void);
+size_t ff_get_cpu_max_align_x86(void);
+
 #endif /* AVUTIL_CPU_INTERNAL_H */
diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index 298185684b..06ad370847 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -142,3 +142,12 @@ out:
 #endif /* HAVE_ALTIVEC */
     return 0;
 }
+
+size_t ff_get_cpu_max_align_ppc(void)
+{
+    int flags = av_get_cpu_flags();
+
+    if (flags & AV_CPU_FLAG_ALTIVEC)
+        return 16;
+    return 8;
+}
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 7c50fe38e2..fa50eeb9dd 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -233,3 +233,14 @@ int ff_get_cpu_flags_x86(void)
 
     return rval;
 }
+
+size_t ff_get_cpu_max_align_x86(void)
+{
+    int flags = av_get_cpu_flags();
+
+    if (flags & AV_CPU_FLAG_AVX)
+        return 32;
+    if (flags & AV_CPU_FLAG_SSE)
+        return 16;
+    return 8;
+}



More information about the ffmpeg-cvslog mailing list