From 8279a152847005a124de1f4b33b35b9c85e1a116 Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 2 Jul 2014 22:16:49 -0300 Subject: x86/swr: split audioconvert and rematrix DSP into separate files Also rename resample_x86_dsp.c to resample_init.c Signed-off-by: James Almer Signed-off-by: Michael Niedermayer --- libswresample/x86/Makefile | 7 +- libswresample/x86/audio_convert_init.c | 140 +++++++++++++++++++++++ libswresample/x86/rematrix_init.c | 80 +++++++++++++ libswresample/x86/resample_init.c | 89 +++++++++++++++ libswresample/x86/resample_x86_dsp.c | 89 --------------- libswresample/x86/swresample_x86.c | 200 --------------------------------- 6 files changed, 313 insertions(+), 292 deletions(-) create mode 100644 libswresample/x86/audio_convert_init.c create mode 100644 libswresample/x86/rematrix_init.c create mode 100644 libswresample/x86/resample_init.c delete mode 100644 libswresample/x86/resample_x86_dsp.c delete mode 100644 libswresample/x86/swresample_x86.c (limited to 'libswresample') diff --git a/libswresample/x86/Makefile b/libswresample/x86/Makefile index cb6371ae1f..be44df56aa 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/audio_convert_init.c b/libswresample/x86/audio_convert_init.c new file mode 100644 index 0000000000..2e1380db20 --- /dev/null +++ b/libswresample/x86/audio_convert_init.c @@ -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 index 0000000000..77a18a2829 --- /dev/null +++ b/libswresample/x86/rematrix_init.c @@ -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; inative_matrix)[i * nb_in + j])); + sh = FFMAX(av_log2(sh) - 14, 0); + for(j=0; jnative_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<>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 index 0000000000..00eb9e14a1 --- /dev/null +++ b/libswresample/x86/resample_init.c @@ -0,0 +1,89 @@ +/* + * audio resampling + * Copyright (c) 2004-2012 Michael Niedermayer + * + * 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 + */ + +#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 index 00eb9e14a1..0000000000 --- a/libswresample/x86/resample_x86_dsp.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * audio resampling - * Copyright (c) 2004-2012 Michael Niedermayer - * - * 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 - */ - -#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 index 7483ba0bed..0000000000 --- a/libswresample/x86/swresample_x86.c +++ /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; inative_matrix)[i * nb_in + j])); - sh = FFMAX(av_log2(sh) - 14, 0); - for(j=0; jnative_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<>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)); - } -} -- cgit v1.2.3