]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/x86/mlpdsp.c
x86: dcadsp: implement SSE lfe_dir
[ffmpeg] / libavcodec / x86 / mlpdsp.c
index a44760bc075e67a771779f6ff070e2a9752fdfd0..72fc637764dcb6275d5ba33bb91888d1012222f9 100644 (file)
@@ -2,44 +2,48 @@
  * MLP DSP functions x86-optimized
  * Copyright (c) 2009 Ramiro Polla
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * 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.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * 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/x86_cpu.h"
-#include "libavcodec/dsputil.h"
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "libavutil/cpu.h"
+#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/mlpdsp.h"
 #include "libavcodec/mlp.h"
 
-#if HAVE_7REGS && HAVE_TEN_OPERANDS
+#if HAVE_7REGS && HAVE_INLINE_ASM
 
-extern void ff_mlp_firorder_8;
-extern void ff_mlp_firorder_7;
-extern void ff_mlp_firorder_6;
-extern void ff_mlp_firorder_5;
-extern void ff_mlp_firorder_4;
-extern void ff_mlp_firorder_3;
-extern void ff_mlp_firorder_2;
-extern void ff_mlp_firorder_1;
-extern void ff_mlp_firorder_0;
+extern char ff_mlp_firorder_8;
+extern char ff_mlp_firorder_7;
+extern char ff_mlp_firorder_6;
+extern char ff_mlp_firorder_5;
+extern char ff_mlp_firorder_4;
+extern char ff_mlp_firorder_3;
+extern char ff_mlp_firorder_2;
+extern char ff_mlp_firorder_1;
+extern char ff_mlp_firorder_0;
 
-extern void ff_mlp_iirorder_4;
-extern void ff_mlp_iirorder_3;
-extern void ff_mlp_iirorder_2;
-extern void ff_mlp_iirorder_1;
-extern void ff_mlp_iirorder_0;
+extern char ff_mlp_iirorder_4;
+extern char ff_mlp_iirorder_3;
+extern char ff_mlp_iirorder_2;
+extern char ff_mlp_iirorder_1;
+extern char ff_mlp_iirorder_0;
 
 static const void *firtable[9] = { &ff_mlp_firorder_0, &ff_mlp_firorder_1,
                                    &ff_mlp_firorder_2, &ff_mlp_firorder_3,
@@ -75,11 +79,6 @@ static const void *iirtable[5] = { &ff_mlp_iirorder_0, &ff_mlp_iirorder_1,
 #define RESULT   "%%rsi"
 #define RESULT32 "%%esi"
 
-#define READVAL "r"
-#define RDWRVAL "+r"
-#define COUNTER "c"
-#define ECXUSED
-
 #else /* if ARCH_X86_32 */
 
 #define MLPMUL(label, offset, offs, offc)  \
@@ -106,11 +105,6 @@ static const void *iirtable[5] = { &ff_mlp_iirorder_0, &ff_mlp_iirorder_1,
 #define RESULT   "%%eax"
 #define RESULT32 "%%eax"
 
-#define READVAL "m"
-#define RDWRVAL "+m"
-#define COUNTER "m"
-#define ECXUSED , "ecx"
-
 #endif /* !ARCH_X86_64 */
 
 #define BINC  AV_STRINGIFY(4* MAX_CHANNELS)
@@ -164,27 +158,30 @@ static void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff,
         : /* 0*/"+r"(state),
           /* 1*/"+r"(coeff),
           /* 2*/"+r"(sample_buffer),
-          /* 3*/RDWRVAL(blocksize)
-        :
-          /* 4*/READVAL((x86_reg)mask),
-          /* 5*/READVAL(firjump),
-          /* 6*/READVAL(iirjump),
-          /* 7*/COUNTER(filter_shift)
 #if ARCH_X86_64
+          /* 3*/"+r"(blocksize)
+        : /* 4*/"r"((x86_reg)mask), /* 5*/"r"(firjump),
+          /* 6*/"r"(iirjump)      , /* 7*/"c"(filter_shift)
         , /* 8*/"r"((int64_t)coeff[0])
         , /* 9*/"r"((int64_t)coeff[1])
         , /*10*/"r"((int64_t)coeff[2])
-#endif /* ARCH_X86_64 */
-        : REG_a, REG_d, REG_S
-          ECXUSED
+        : "rax", "rdx", "rsi"
+#else /* ARCH_X86_32 */
+          /* 3*/"+m"(blocksize)
+        : /* 4*/"m"(         mask), /* 5*/"m"(firjump),
+          /* 6*/"m"(iirjump)      , /* 7*/"m"(filter_shift)
+        : "eax", "edx", "esi", "ecx"
+#endif /* !ARCH_X86_64 */
     );
 }
 
-#endif /* HAVE_7REGS && HAVE_TEN_OPERANDS */
+#endif /* HAVE_7REGS && HAVE_INLINE_ASM */
 
-void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx)
+av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c)
 {
-#if HAVE_7REGS && HAVE_TEN_OPERANDS
-    c->mlp_filter_channel = mlp_filter_channel_x86;
+#if HAVE_7REGS && HAVE_INLINE_ASM
+    int cpu_flags = av_get_cpu_flags();
+    if (INLINE_MMX(cpu_flags))
+        c->mlp_filter_channel = mlp_filter_channel_x86;
 #endif
 }