3 * Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 * @author Michael Niedermayer <michaelni@gmx.at>
28 #include "libswresample/resample.h"
30 #define RESAMPLE_FUNCS(type, opt) \
31 int ff_resample_common_##type##_##opt(ResampleContext *c, uint8_t *dst, \
32 const uint8_t *src, int sz, int upd); \
33 int ff_resample_linear_##type##_##opt(ResampleContext *c, uint8_t *dst, \
34 const uint8_t *src, int sz, int upd)
36 RESAMPLE_FUNCS(int16, mmxext);
37 RESAMPLE_FUNCS(int16, sse2);
38 RESAMPLE_FUNCS(int16, xop);
39 RESAMPLE_FUNCS(float, sse);
40 RESAMPLE_FUNCS(float, avx);
41 RESAMPLE_FUNCS(float, fma3);
42 RESAMPLE_FUNCS(float, fma4);
43 RESAMPLE_FUNCS(double, sse2);
45 void swresample_dsp_x86_init(ResampleContext *c)
47 int av_unused mm_flags = av_get_cpu_flags();
49 #define FNIDX(fmt) (AV_SAMPLE_FMT_##fmt - AV_SAMPLE_FMT_S16P)
50 if (ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL && mm_flags & AV_CPU_FLAG_MMX2) {
51 c->dsp.resample_common[FNIDX(S16P)] = ff_resample_common_int16_mmxext;
52 c->dsp.resample_linear[FNIDX(S16P)] = ff_resample_linear_int16_mmxext;
54 if (HAVE_SSE_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE) {
55 c->dsp.resample_common[FNIDX(FLTP)] = ff_resample_common_float_sse;
56 c->dsp.resample_linear[FNIDX(FLTP)] = ff_resample_linear_float_sse;
58 if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
59 c->dsp.resample_common[FNIDX(S16P)] = ff_resample_common_int16_sse2;
60 c->dsp.resample_linear[FNIDX(S16P)] = ff_resample_linear_int16_sse2;
62 c->dsp.resample_common[FNIDX(DBLP)] = ff_resample_common_double_sse2;
63 c->dsp.resample_linear[FNIDX(DBLP)] = ff_resample_linear_double_sse2;
65 if (HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
66 c->dsp.resample_common[FNIDX(FLTP)] = ff_resample_common_float_avx;
67 c->dsp.resample_linear[FNIDX(FLTP)] = ff_resample_linear_float_avx;
69 if (HAVE_FMA3_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA3) {
70 c->dsp.resample_common[FNIDX(FLTP)] = ff_resample_common_float_fma3;
71 c->dsp.resample_linear[FNIDX(FLTP)] = ff_resample_linear_float_fma3;
73 if (HAVE_FMA4_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA4) {
74 c->dsp.resample_common[FNIDX(FLTP)] = ff_resample_common_float_fma4;
75 c->dsp.resample_linear[FNIDX(FLTP)] = ff_resample_linear_float_fma4;
77 if (HAVE_XOP_EXTERNAL && mm_flags & AV_CPU_FLAG_XOP) {
78 c->dsp.resample_common[FNIDX(S16P)] = ff_resample_common_int16_xop;
79 c->dsp.resample_linear[FNIDX(S16P)] = ff_resample_linear_int16_xop;