FFmpeg
Loading...
Searching...
No Matches
resample_init.c
Go to the documentation of this file.
1/*
2 * audio resampling
3 * Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of FFmpeg.
6 *
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.
11 *
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.
16 *
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
20 */
21
22/**
23 * @file
24 * audio resampling
25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */
27
29#include "libavutil/x86/cpu.h"
31
32#define RESAMPLE_FUNCS(type, opt) \
33int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
34 const void *src, int sz, int upd); \
35int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
36 const void *src, int sz, int upd)
37
38RESAMPLE_FUNCS(int16, sse2);
39RESAMPLE_FUNCS(int16, xop);
41RESAMPLE_FUNCS(float, avx);
42RESAMPLE_FUNCS(float, fma3);
43RESAMPLE_FUNCS(float, fma4);
44RESAMPLE_FUNCS(double, sse2);
45RESAMPLE_FUNCS(double, avx);
46RESAMPLE_FUNCS(double, fma3);
47
49{
50 av_unused int mm_flags = av_get_cpu_flags();
51
52 switch(c->format){
54 if (EXTERNAL_SSE2(mm_flags)) {
55 c->dsp.resample_linear = ff_resample_linear_int16_sse2;
56 c->dsp.resample_common = ff_resample_common_int16_sse2;
57 }
58 if (EXTERNAL_XOP(mm_flags)) {
59 c->dsp.resample_linear = ff_resample_linear_int16_xop;
60 c->dsp.resample_common = ff_resample_common_int16_xop;
61 }
62 break;
64 if (EXTERNAL_SSE(mm_flags)) {
65 c->dsp.resample_linear = ff_resample_linear_float_sse;
66 c->dsp.resample_common = ff_resample_common_float_sse;
67 }
68 if (EXTERNAL_AVX_FAST(mm_flags)) {
69 c->dsp.resample_linear = ff_resample_linear_float_avx;
70 c->dsp.resample_common = ff_resample_common_float_avx;
71 }
72 if (EXTERNAL_FMA3_FAST(mm_flags)) {
73 c->dsp.resample_linear = ff_resample_linear_float_fma3;
74 c->dsp.resample_common = ff_resample_common_float_fma3;
75 }
76 if (EXTERNAL_FMA4(mm_flags)) {
77 c->dsp.resample_linear = ff_resample_linear_float_fma4;
78 c->dsp.resample_common = ff_resample_common_float_fma4;
79 }
80 break;
82 if (EXTERNAL_SSE2(mm_flags)) {
83 c->dsp.resample_linear = ff_resample_linear_double_sse2;
84 c->dsp.resample_common = ff_resample_common_double_sse2;
85 }
86 if (EXTERNAL_AVX_FAST(mm_flags)) {
87 c->dsp.resample_linear = ff_resample_linear_double_avx;
88 c->dsp.resample_common = ff_resample_common_double_avx;
89 }
90 if (EXTERNAL_FMA3_FAST(mm_flags)) {
91 c->dsp.resample_linear = ff_resample_linear_double_fma3;
92 c->dsp.resample_common = ff_resample_common_double_fma3;
93 }
94 break;
95 }
96}
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition samplefmt.h:64
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition samplefmt.h:67
Macro definitions for various function/variable attributes.
#define av_unused
Definition attributes.h:164
#define av_cold
Definition attributes.h:117
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_SSE(flags)
Definition cpu.h:52
#define EXTERNAL_XOP(flags)
Definition cpu.h:67
#define EXTERNAL_FMA3_FAST(flags)
Definition cpu.h:69
#define EXTERNAL_FMA4(flags)
Definition cpu.h:71
#define EXTERNAL_AVX_FAST(flags)
Definition cpu.h:65
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
static int sse(const MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride)
static double c[64]
av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
#define RESAMPLE_FUNCS(type, opt)