x86/swr: split audioconvert and rematrix DSP into separate files
authorJames Almer <jamrial@gmail.com>
Thu, 3 Jul 2014 01:16:49 +0000 (22:16 -0300)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 4 Jul 2014 00:00:11 +0000 (02:00 +0200)
Also rename resample_x86_dsp.c to resample_init.c

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/x86/Makefile
libswresample/x86/audio_convert_init.c [new file with mode: 0644]
libswresample/x86/rematrix_init.c [new file with mode: 0644]
libswresample/x86/resample_init.c [new file with mode: 0644]
libswresample/x86/resample_x86_dsp.c [deleted file]
libswresample/x86/swresample_x86.c [deleted file]

index cb6371a..be44df5 100644 (file)
@@ -1,8 +1,9 @@
-YASM-OBJS                       += x86/swresample_x86.o\
-                                   x86/audio_convert.o\
+YASM-OBJS                       += x86/audio_convert.o\
                                    x86/rematrix.o\
                                    x86/resample.o\
 
-OBJS                            += x86/resample_x86_dsp.o\
+OBJS                            += x86/audio_convert_init.o\
+                                   x86/rematrix_init.o\
+                                   x86/resample_init.o\
 
 OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
diff --git a/libswresample/x86/audio_convert_init.c b/libswresample/x86/audio_convert_init.c
new file mode 100644 (file)
index 0000000..2e1380d
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
+ *
+ * This file is part of libswresample
+ *
+ * libswresample 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.
+ *
+ * libswresample 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 libswresample; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libswresample/swresample_internal.h"
+#include "libswresample/audioconvert.h"
+
+#define PROTO(pre, in, out, cap) void ff ## pre ## in## _to_ ##out## _a_ ##cap(uint8_t **dst, const uint8_t **src, int len);
+#define PROTO2(pre, out, cap) PROTO(pre, int16, out, cap) PROTO(pre, int32, out, cap) PROTO(pre, float, out, cap)
+#define PROTO3(pre, cap) PROTO2(pre, int16, cap) PROTO2(pre, int32, cap) PROTO2(pre, float, cap)
+#define PROTO4(pre) PROTO3(pre, mmx) PROTO3(pre, sse) PROTO3(pre, sse2) PROTO3(pre, ssse3) PROTO3(pre, sse4) PROTO3(pre, avx)
+PROTO4(_)
+PROTO4(_pack_2ch_)
+PROTO4(_pack_6ch_)
+PROTO4(_unpack_2ch_)
+
+av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
+                                 enum AVSampleFormat out_fmt,
+                                 enum AVSampleFormat in_fmt,
+                                 int channels){
+    int mm_flags = av_get_cpu_flags();
+
+    ac->simd_f= NULL;
+
+//FIXME add memcpy case
+
+#define MULTI_CAPS_FUNC(flag, cap) \
+    if (mm_flags & flag) {\
+        if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
+            ac->simd_f =  ff_int16_to_int32_a_ ## cap;\
+        if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
+            ac->simd_f =  ff_int32_to_int16_a_ ## cap;\
+    }
+
+MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
+MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
+
+    if(mm_flags & AV_CPU_FLAG_MMX) {
+        if(channels == 6) {
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_float_to_float_a_mmx;
+        }
+    }
+
+    if(mm_flags & AV_CPU_FLAG_SSE2) {
+        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
+            ac->simd_f =  ff_int32_to_float_a_sse2;
+        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
+            ac->simd_f =  ff_int16_to_float_a_sse2;
+        if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
+            ac->simd_f =  ff_float_to_int32_a_sse2;
+        if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
+            ac->simd_f =  ff_float_to_int16_a_sse2;
+
+        if(channels == 2) {
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_2ch_int32_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S16P)
+                ac->simd_f =  ff_pack_2ch_int16_to_int16_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16P)
+                ac->simd_f =  ff_pack_2ch_int16_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_2ch_int32_to_int16_a_sse2;
+
+            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
+                ac->simd_f =  ff_unpack_2ch_int32_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S32)
+                ac->simd_f =  ff_unpack_2ch_int32_to_int16_a_sse2;
+
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_2ch_int32_to_float_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
+                ac->simd_f =  ff_pack_2ch_float_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16P)
+                ac->simd_f =  ff_pack_2ch_int16_to_float_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLTP)
+                ac->simd_f =  ff_pack_2ch_float_to_int16_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S32)
+                ac->simd_f =  ff_unpack_2ch_int32_to_float_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_FLT)
+                ac->simd_f =  ff_unpack_2ch_float_to_int32_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_float_a_sse2;
+            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_FLT)
+                ac->simd_f =  ff_unpack_2ch_float_to_int16_a_sse2;
+        }
+    }
+    if(mm_flags & AV_CPU_FLAG_SSSE3) {
+        if(channels == 2) {
+            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_ssse3;
+            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_ssse3;
+            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
+                ac->simd_f =  ff_unpack_2ch_int16_to_float_a_ssse3;
+        }
+    }
+    if(mm_flags & AV_CPU_FLAG_SSE4) {
+        if(channels == 6) {
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_float_to_float_a_sse4;
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_int32_to_float_a_sse4;
+            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
+                ac->simd_f =  ff_pack_6ch_float_to_int32_a_sse4;
+        }
+    }
+    if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
+        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
+            ac->simd_f =  ff_int32_to_float_a_avx;
+        if(channels == 6) {
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_float_to_float_a_avx;
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_int32_to_float_a_avx;
+            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
+                ac->simd_f =  ff_pack_6ch_float_to_int32_a_avx;
+        }
+    }
+}
diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c
new file mode 100644 (file)
index 0000000..77a18a2
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
+ *
+ * This file is part of libswresample
+ *
+ * libswresample 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.
+ *
+ * libswresample 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 libswresample; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libswresample/swresample_internal.h"
+
+#define D(type, simd) \
+mix_1_1_func_type ff_mix_1_1_a_## type ## _ ## simd;\
+mix_2_1_func_type ff_mix_2_1_a_## type ## _ ## simd;
+
+D(float, sse)
+D(float, avx)
+D(int16, mmx)
+D(int16, sse2)
+
+av_cold void swri_rematrix_init_x86(struct SwrContext *s){
+    int mm_flags = av_get_cpu_flags();
+    int nb_in  = av_get_channel_layout_nb_channels(s->in_ch_layout);
+    int nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout);
+    int num    = nb_in * nb_out;
+    int i,j;
+
+    s->mix_1_1_simd = NULL;
+    s->mix_2_1_simd = NULL;
+
+    if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
+        if(mm_flags & AV_CPU_FLAG_MMX) {
+            s->mix_1_1_simd = ff_mix_1_1_a_int16_mmx;
+            s->mix_2_1_simd = ff_mix_2_1_a_int16_mmx;
+        }
+        if(mm_flags & AV_CPU_FLAG_SSE2) {
+            s->mix_1_1_simd = ff_mix_1_1_a_int16_sse2;
+            s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2;
+        }
+        s->native_simd_matrix = av_mallocz(2 * num * sizeof(int16_t));
+        s->native_simd_one    = av_mallocz(2 * sizeof(int16_t));
+        for(i=0; i<nb_out; i++){
+            int sh = 0;
+            for(j=0; j<nb_in; j++)
+                sh = FFMAX(sh, FFABS(((int*)s->native_matrix)[i * nb_in + j]));
+            sh = FFMAX(av_log2(sh) - 14, 0);
+            for(j=0; j<nb_in; j++) {
+                ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)+1] = 15 - sh;
+                ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)] =
+                    ((((int*)s->native_matrix)[i * nb_in + j]) + (1<<sh>>1)) >> sh;
+            }
+        }
+        ((int16_t*)s->native_simd_one)[1] = 14;
+        ((int16_t*)s->native_simd_one)[0] = 16384;
+    } else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
+        if(mm_flags & AV_CPU_FLAG_SSE) {
+            s->mix_1_1_simd = ff_mix_1_1_a_float_sse;
+            s->mix_2_1_simd = ff_mix_2_1_a_float_sse;
+        }
+        if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
+            s->mix_1_1_simd = ff_mix_1_1_a_float_avx;
+            s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
+        }
+        s->native_simd_matrix = av_mallocz(num * sizeof(float));
+        memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
+        s->native_simd_one = av_mallocz(sizeof(float));
+        memcpy(s->native_simd_one, s->native_one, sizeof(float));
+    }
+}
diff --git a/libswresample/x86/resample_init.c b/libswresample/x86/resample_init.c
new file mode 100644 (file)
index 0000000..00eb9e1
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * audio resampling
+ * Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * audio resampling
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#include "libswresample/resample.h"
+
+#define RESAMPLE_FUNCS(type, opt) \
+int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
+                                      const void *src, int sz, int upd); \
+int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
+                                      const void *src, int sz, int upd)
+
+RESAMPLE_FUNCS(int16,  mmxext);
+RESAMPLE_FUNCS(int16,  sse2);
+RESAMPLE_FUNCS(int16,  xop);
+RESAMPLE_FUNCS(float,  sse);
+RESAMPLE_FUNCS(float,  avx);
+RESAMPLE_FUNCS(float,  fma3);
+RESAMPLE_FUNCS(float,  fma4);
+RESAMPLE_FUNCS(double, sse2);
+
+void swri_resample_dsp_x86_init(ResampleContext *c)
+{
+    int av_unused mm_flags = av_get_cpu_flags();
+
+    switch(c->format){
+    case AV_SAMPLE_FMT_S16P:
+        if (ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL && mm_flags & AV_CPU_FLAG_MMX2) {
+            c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
+                                        : ff_resample_common_int16_mmxext;
+        }
+        if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
+            c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
+                                        : ff_resample_common_int16_sse2;
+        }
+        if (HAVE_XOP_EXTERNAL && mm_flags & AV_CPU_FLAG_XOP) {
+            c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
+                                        : ff_resample_common_int16_xop;
+        }
+        break;
+    case AV_SAMPLE_FMT_FLTP:
+        if (HAVE_SSE_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE) {
+            c->dsp.resample = c->linear ? ff_resample_linear_float_sse
+                                        : ff_resample_common_float_sse;
+        }
+        if (HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
+            c->dsp.resample = c->linear ? ff_resample_linear_float_avx
+                                        : ff_resample_common_float_avx;
+        }
+        if (HAVE_FMA3_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA3) {
+            c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
+                                        : ff_resample_common_float_fma3;
+        }
+        if (HAVE_FMA4_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA4) {
+            c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
+                                        : ff_resample_common_float_fma4;
+        }
+        break;
+    case AV_SAMPLE_FMT_DBLP:
+        if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
+            c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
+                                        : ff_resample_common_double_sse2;
+        }
+        break;
+    }
+}
diff --git a/libswresample/x86/resample_x86_dsp.c b/libswresample/x86/resample_x86_dsp.c
deleted file mode 100644 (file)
index 00eb9e1..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * audio resampling
- * Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg 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,
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * audio resampling
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libswresample/resample.h"
-
-#define RESAMPLE_FUNCS(type, opt) \
-int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
-                                      const void *src, int sz, int upd); \
-int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
-                                      const void *src, int sz, int upd)
-
-RESAMPLE_FUNCS(int16,  mmxext);
-RESAMPLE_FUNCS(int16,  sse2);
-RESAMPLE_FUNCS(int16,  xop);
-RESAMPLE_FUNCS(float,  sse);
-RESAMPLE_FUNCS(float,  avx);
-RESAMPLE_FUNCS(float,  fma3);
-RESAMPLE_FUNCS(float,  fma4);
-RESAMPLE_FUNCS(double, sse2);
-
-void swri_resample_dsp_x86_init(ResampleContext *c)
-{
-    int av_unused mm_flags = av_get_cpu_flags();
-
-    switch(c->format){
-    case AV_SAMPLE_FMT_S16P:
-        if (ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL && mm_flags & AV_CPU_FLAG_MMX2) {
-            c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
-                                        : ff_resample_common_int16_mmxext;
-        }
-        if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
-            c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
-                                        : ff_resample_common_int16_sse2;
-        }
-        if (HAVE_XOP_EXTERNAL && mm_flags & AV_CPU_FLAG_XOP) {
-            c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
-                                        : ff_resample_common_int16_xop;
-        }
-        break;
-    case AV_SAMPLE_FMT_FLTP:
-        if (HAVE_SSE_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE) {
-            c->dsp.resample = c->linear ? ff_resample_linear_float_sse
-                                        : ff_resample_common_float_sse;
-        }
-        if (HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
-            c->dsp.resample = c->linear ? ff_resample_linear_float_avx
-                                        : ff_resample_common_float_avx;
-        }
-        if (HAVE_FMA3_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA3) {
-            c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
-                                        : ff_resample_common_float_fma3;
-        }
-        if (HAVE_FMA4_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA4) {
-            c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
-                                        : ff_resample_common_float_fma4;
-        }
-        break;
-    case AV_SAMPLE_FMT_DBLP:
-        if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
-            c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
-                                        : ff_resample_common_double_sse2;
-        }
-        break;
-    }
-}
diff --git a/libswresample/x86/swresample_x86.c b/libswresample/x86/swresample_x86.c
deleted file mode 100644 (file)
index 7483ba0..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
- *
- * This file is part of libswresample
- *
- * libswresample 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.
- *
- * libswresample 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 libswresample; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libswresample/swresample_internal.h"
-#include "libswresample/audioconvert.h"
-
-#define PROTO(pre, in, out, cap) void ff ## pre ## in## _to_ ##out## _a_ ##cap(uint8_t **dst, const uint8_t **src, int len);
-#define PROTO2(pre, out, cap) PROTO(pre, int16, out, cap) PROTO(pre, int32, out, cap) PROTO(pre, float, out, cap)
-#define PROTO3(pre, cap) PROTO2(pre, int16, cap) PROTO2(pre, int32, cap) PROTO2(pre, float, cap)
-#define PROTO4(pre) PROTO3(pre, mmx) PROTO3(pre, sse) PROTO3(pre, sse2) PROTO3(pre, ssse3) PROTO3(pre, sse4) PROTO3(pre, avx)
-PROTO4(_)
-PROTO4(_pack_2ch_)
-PROTO4(_pack_6ch_)
-PROTO4(_unpack_2ch_)
-
-av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
-                                 enum AVSampleFormat out_fmt,
-                                 enum AVSampleFormat in_fmt,
-                                 int channels){
-    int mm_flags = av_get_cpu_flags();
-
-    ac->simd_f= NULL;
-
-//FIXME add memcpy case
-
-#define MULTI_CAPS_FUNC(flag, cap) \
-    if (mm_flags & flag) {\
-        if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
-            ac->simd_f =  ff_int16_to_int32_a_ ## cap;\
-        if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
-            ac->simd_f =  ff_int32_to_int16_a_ ## cap;\
-    }
-
-MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
-MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
-
-    if(mm_flags & AV_CPU_FLAG_MMX) {
-        if(channels == 6) {
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_6ch_float_to_float_a_mmx;
-        }
-    }
-
-    if(mm_flags & AV_CPU_FLAG_SSE2) {
-        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
-            ac->simd_f =  ff_int32_to_float_a_sse2;
-        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
-            ac->simd_f =  ff_int16_to_float_a_sse2;
-        if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
-            ac->simd_f =  ff_float_to_int32_a_sse2;
-        if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
-            ac->simd_f =  ff_float_to_int16_a_sse2;
-
-        if(channels == 2) {
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_2ch_int32_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S16P)
-                ac->simd_f =  ff_pack_2ch_int16_to_int16_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16P)
-                ac->simd_f =  ff_pack_2ch_int16_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_2ch_int32_to_int16_a_sse2;
-
-            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
-                ac->simd_f =  ff_unpack_2ch_int32_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S32)
-                ac->simd_f =  ff_unpack_2ch_int32_to_int16_a_sse2;
-
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_2ch_int32_to_float_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
-                ac->simd_f =  ff_pack_2ch_float_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16P)
-                ac->simd_f =  ff_pack_2ch_int16_to_float_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLTP)
-                ac->simd_f =  ff_pack_2ch_float_to_int16_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S32)
-                ac->simd_f =  ff_unpack_2ch_int32_to_float_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_FLT)
-                ac->simd_f =  ff_unpack_2ch_float_to_int32_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_float_a_sse2;
-            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_FLT)
-                ac->simd_f =  ff_unpack_2ch_float_to_int16_a_sse2;
-        }
-    }
-    if(mm_flags & AV_CPU_FLAG_SSSE3) {
-        if(channels == 2) {
-            if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_ssse3;
-            if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_ssse3;
-            if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
-                ac->simd_f =  ff_unpack_2ch_int16_to_float_a_ssse3;
-        }
-    }
-    if(mm_flags & AV_CPU_FLAG_SSE4) {
-        if(channels == 6) {
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_6ch_float_to_float_a_sse4;
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_6ch_int32_to_float_a_sse4;
-            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
-                ac->simd_f =  ff_pack_6ch_float_to_int32_a_sse4;
-        }
-    }
-    if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
-        if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
-            ac->simd_f =  ff_int32_to_float_a_avx;
-        if(channels == 6) {
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_6ch_float_to_float_a_avx;
-            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
-                ac->simd_f =  ff_pack_6ch_int32_to_float_a_avx;
-            if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
-                ac->simd_f =  ff_pack_6ch_float_to_int32_a_avx;
-        }
-    }
-}
-
-#define D(type, simd) \
-mix_1_1_func_type ff_mix_1_1_a_## type ## _ ## simd;\
-mix_2_1_func_type ff_mix_2_1_a_## type ## _ ## simd;
-
-D(float, sse)
-D(float, avx)
-D(int16, mmx)
-D(int16, sse2)
-
-
-av_cold void swri_rematrix_init_x86(struct SwrContext *s){
-    int mm_flags = av_get_cpu_flags();
-    int nb_in  = av_get_channel_layout_nb_channels(s->in_ch_layout);
-    int nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout);
-    int num    = nb_in * nb_out;
-    int i,j;
-
-    s->mix_1_1_simd = NULL;
-    s->mix_2_1_simd = NULL;
-
-    if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
-        if(mm_flags & AV_CPU_FLAG_MMX) {
-            s->mix_1_1_simd = ff_mix_1_1_a_int16_mmx;
-            s->mix_2_1_simd = ff_mix_2_1_a_int16_mmx;
-        }
-        if(mm_flags & AV_CPU_FLAG_SSE2) {
-            s->mix_1_1_simd = ff_mix_1_1_a_int16_sse2;
-            s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2;
-        }
-        s->native_simd_matrix = av_mallocz(2 * num * sizeof(int16_t));
-        s->native_simd_one    = av_mallocz(2 * sizeof(int16_t));
-        for(i=0; i<nb_out; i++){
-            int sh = 0;
-            for(j=0; j<nb_in; j++)
-                sh = FFMAX(sh, FFABS(((int*)s->native_matrix)[i * nb_in + j]));
-            sh = FFMAX(av_log2(sh) - 14, 0);
-            for(j=0; j<nb_in; j++) {
-                ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)+1] = 15 - sh;
-                ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)] =
-                    ((((int*)s->native_matrix)[i * nb_in + j]) + (1<<sh>>1)) >> sh;
-            }
-        }
-        ((int16_t*)s->native_simd_one)[1] = 14;
-        ((int16_t*)s->native_simd_one)[0] = 16384;
-    } else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
-        if(mm_flags & AV_CPU_FLAG_SSE) {
-            s->mix_1_1_simd = ff_mix_1_1_a_float_sse;
-            s->mix_2_1_simd = ff_mix_2_1_a_float_sse;
-        }
-        if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
-            s->mix_1_1_simd = ff_mix_1_1_a_float_avx;
-            s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
-        }
-        s->native_simd_matrix = av_mallocz(num * sizeof(float));
-        memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
-        s->native_simd_one = av_mallocz(sizeof(float));
-        memcpy(s->native_simd_one, s->native_one, sizeof(float));
-    }
-}