[FFmpeg-devel] [PATCH 2/3] x86/swr: split audioconvert and rematrix DSP into separate files

James Almer jamrial at gmail.com
Thu Jul 3 03:16:49 CEST 2014


Also rename resample_x86_dsp.c to resample_init.c

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libswresample/x86/Makefile                         |  7 +-
 .../x86/{swresample_x86.c => audio_convert_init.c} | 60 ----------------
 libswresample/x86/rematrix_init.c                  | 80 ++++++++++++++++++++++
 .../x86/{resample_x86_dsp.c => resample_init.c}    |  0
 4 files changed, 84 insertions(+), 63 deletions(-)
 rename libswresample/x86/{swresample_x86.c => audio_convert_init.c} (77%)
 create mode 100644 libswresample/x86/rematrix_init.c
 rename libswresample/x86/{resample_x86_dsp.c => resample_init.c} (100%)

diff --git a/libswresample/x86/Makefile b/libswresample/x86/Makefile
index cb6371a..be44df5 100644
--- a/libswresample/x86/Makefile
+++ b/libswresample/x86/Makefile
@@ -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/swresample_x86.c b/libswresample/x86/audio_convert_init.c
similarity index 77%
rename from libswresample/x86/swresample_x86.c
rename to libswresample/x86/audio_convert_init.c
index 7483ba0..2e1380d 100644
--- a/libswresample/x86/swresample_x86.c
+++ b/libswresample/x86/audio_convert_init.c
@@ -138,63 +138,3 @@ MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
         }
     }
 }
-
-#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/rematrix_init.c b/libswresample/x86/rematrix_init.c
new file mode 100644
index 0000000..77a18a2
--- /dev/null
+++ b/libswresample/x86/rematrix_init.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 Michael Niedermayer (michaelni at 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_x86_dsp.c b/libswresample/x86/resample_init.c
similarity index 100%
rename from libswresample/x86/resample_x86_dsp.c
rename to libswresample/x86/resample_init.c
-- 
1.8.5.5



More information about the ffmpeg-devel mailing list