]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/x86/gradfun.c
x86: mmx2 ---> mmxext in function names
[ffmpeg] / libavfilter / x86 / gradfun.c
index 894a44b9ff81d218f57149bff42b71e160833500..b4ca86c617137022f3fa906ed7f5d8a40c73ebba 100644 (file)
@@ -1,31 +1,39 @@
 /*
- * This file is part of FFmpeg.
+ * Copyright (C) 2009 Loren Merritt <lorenm@u.washignton.edu>
  *
- * FFmpeg is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This file is part of Libav.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/x86_cpu.h"
+#include "libavutil/mem.h"
+#include "libavutil/x86/asm.h"
 #include "libavfilter/gradfun.h"
 
+#if HAVE_INLINE_ASM
+
 DECLARE_ALIGNED(16, static const uint16_t, pw_7f)[8] = {0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F};
 DECLARE_ALIGNED(16, static const uint16_t, pw_ff)[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
 
-void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
+#if HAVE_MMXEXT_INLINE
+static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
+                                       int width, int thresh,
+                                       const uint16_t *dithers)
 {
-#if HAVE_MMX
     intptr_t x;
     if (width & 3) {
         x = width & ~3;
@@ -68,12 +76,12 @@ void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int w
          "rm"(thresh), "m"(*dithers), "m"(*pw_7f)
         :"memory"
     );
-#endif
 }
+#endif
 
-void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
+#if HAVE_SSSE3_INLINE
+static void gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
 {
-#if HAVE_SSSE3
     intptr_t x;
     if (width & 7) {
         // could be 10% faster if I somehow eliminated this
@@ -115,12 +123,12 @@ void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int
          "rm"(thresh), "m"(*dithers), "m"(*pw_7f)
         :"memory"
     );
-#endif // HAVE_SSSE3
 }
+#endif /* HAVE_SSSE3_INLINE */
 
-void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
+#if HAVE_SSE2_INLINE
+static void gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
 {
-#if HAVE_SSE
 #define BLURV(load)\
     intptr_t x = -2*width;\
     __asm__ volatile(\
@@ -158,5 +166,25 @@ void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint
     } else {
         BLURV("movdqa");
     }
-#endif // HAVE_SSE
+}
+#endif /* HAVE_SSE2_INLINE */
+
+#endif /* HAVE_INLINE_ASM */
+
+av_cold void ff_gradfun_init_x86(GradFunContext *gf)
+{
+    int cpu_flags = av_get_cpu_flags();
+
+#if HAVE_MMXEXT_INLINE
+    if (cpu_flags & AV_CPU_FLAG_MMXEXT)
+        gf->filter_line = gradfun_filter_line_mmxext;
+#endif
+#if HAVE_SSSE3_INLINE
+    if (cpu_flags & AV_CPU_FLAG_SSSE3)
+        gf->filter_line = gradfun_filter_line_ssse3;
+#endif
+#if HAVE_SSE2_INLINE
+    if (cpu_flags & AV_CPU_FLAG_SSE2)
+        gf->blur_line = gradfun_blur_line_sse2;
+#endif
 }