FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
28 #include "libavutil/x86/cpu.h"
29 #include "libswresample/resample.h"
30 
31 #define RESAMPLE_FUNCS(type, opt) \
32 int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
33  const void *src, int sz, int upd); \
34 int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
35  const void *src, int sz, int upd)
36 
37 RESAMPLE_FUNCS(int16, mmxext);
38 RESAMPLE_FUNCS(int16, sse2);
39 RESAMPLE_FUNCS(int16, xop);
40 RESAMPLE_FUNCS(float, sse);
41 RESAMPLE_FUNCS(float, avx);
42 RESAMPLE_FUNCS(float, fma3);
43 RESAMPLE_FUNCS(float, fma4);
44 RESAMPLE_FUNCS(double, sse2);
45 
47 {
48  int av_unused mm_flags = av_get_cpu_flags();
49 
50  switch(c->format){
51  case AV_SAMPLE_FMT_S16P:
52  if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) {
53  c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
54  : ff_resample_common_int16_mmxext;
55  }
56  if (EXTERNAL_SSE2(mm_flags)) {
57  c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
58  : ff_resample_common_int16_sse2;
59  }
60  if (EXTERNAL_XOP(mm_flags)) {
61  c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
62  : ff_resample_common_int16_xop;
63  }
64  break;
65  case AV_SAMPLE_FMT_FLTP:
66  if (EXTERNAL_SSE(mm_flags)) {
67  c->dsp.resample = c->linear ? ff_resample_linear_float_sse
68  : ff_resample_common_float_sse;
69  }
70  if (EXTERNAL_AVX_FAST(mm_flags)) {
71  c->dsp.resample = c->linear ? ff_resample_linear_float_avx
72  : ff_resample_common_float_avx;
73  }
74  if (EXTERNAL_FMA3_FAST(mm_flags)) {
75  c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
76  : ff_resample_common_float_fma3;
77  }
78  if (EXTERNAL_FMA4(mm_flags)) {
79  c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
80  : ff_resample_common_float_fma4;
81  }
82  break;
83  case AV_SAMPLE_FMT_DBLP:
84  if (EXTERNAL_SSE2(mm_flags)) {
85  c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
86  : ff_resample_common_double_sse2;
87  }
88  break;
89  }
90 }
float, planar
Definition: samplefmt.h:70
double, planar
Definition: samplefmt.h:71
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride)
#define EXTERNAL_SSE(flags)
Definition: cpu.h:56
enum AVSampleFormat format
Definition: resample.h:49
#define av_cold
Definition: attributes.h:82
#define EXTERNAL_AVX_FAST(flags)
Definition: cpu.h:67
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:57
#define EXTERNAL_FMA4(flags)
Definition: cpu.h:73
av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
Definition: resample_init.c:46
struct ResampleContext::@202 dsp
#define EXTERNAL_FMA3_FAST(flags)
Definition: cpu.h:71
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:76
int(* resample)(struct ResampleContext *c, void *dst, const void *src, int n, int update_ctx)
Definition: resample.h:56
#define EXTERNAL_MMXEXT(flags)
Definition: cpu.h:55
static double c[64]
#define EXTERNAL_XOP(flags)
Definition: cpu.h:69
signed 16 bits, planar
Definition: samplefmt.h:68
#define RESAMPLE_FUNCS(type, opt)
Definition: resample_init.c:31
#define av_unused
Definition: attributes.h:126