[FFmpeg-cvslog] x86/intmath: add VEX encoded versions of av_clipf() and av_clipd()

James Almer git at videolan.org
Fri Nov 19 16:30:22 EET 2021


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Nov 15 23:15:38 2021 -0300| [67b92d68c68bc2fac682ca3671003913498bc44c] | committer: James Almer

x86/intmath: add VEX encoded versions of av_clipf() and av_clipd()

Prevents mixing inlined SSE instructions and AVX instructions when the compiler
generates the latter.

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavutil/x86/intmath.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index 1520c25ec9..8a6b5ae261 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -134,6 +134,36 @@ static av_always_inline av_const float av_clipf_sse(float a, float amin, float a
 
 #endif /* __SSE__ */
 
+#if defined(__AVX__) && !defined(__INTEL_COMPILER)
+
+#undef av_clipd
+#define av_clipd av_clipd_avx
+static av_always_inline av_const double av_clipd_avx(double a, double amin, double amax)
+{
+#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
+    if (amin > amax) abort();
+#endif
+    __asm__ ("vmaxsd %1, %0, %0 \n\t"
+             "vminsd %2, %0, %0 \n\t"
+             : "+&x"(a) : "xm"(amin), "xm"(amax));
+    return a;
+}
+
+#undef av_clipf
+#define av_clipf av_clipf_avx
+static av_always_inline av_const float av_clipf_avx(float a, float amin, float amax)
+{
+#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
+    if (amin > amax) abort();
+#endif
+    __asm__ ("vmaxss %1, %0, %0 \n\t"
+             "vminss %2, %0, %0 \n\t"
+             : "+&x"(a) : "xm"(amin), "xm"(amax));
+    return a;
+}
+
+#endif /* __AVX__ */
+
 #endif /* __GNUC__ */
 
 #endif /* AVUTIL_X86_INTMATH_H */



More information about the ffmpeg-cvslog mailing list