]> git.sesse.net Git - ffmpeg/blob - libswresample/resample_dsp.c
Merge commit '5e7b125b6ae36893dfd9cb5661c99b67363cbb38'
[ffmpeg] / libswresample / resample_dsp.c
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 "resample.h"
29
30 int swri_resample_common_int16 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
31 int swri_resample_common_int32 (ResampleContext *c, int32_t *dst, const int32_t *src, int n, int update_ctx);
32 int swri_resample_common_float (ResampleContext *c,   float *dst, const   float *src, int n, int update_ctx);
33 int swri_resample_common_double(ResampleContext *c,  double *dst, const  double *src, int n, int update_ctx);
34 int swri_resample_linear_int16 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
35 int swri_resample_linear_int32 (ResampleContext *c, int32_t *dst, const int32_t *src, int n, int update_ctx);
36 int swri_resample_linear_float (ResampleContext *c,   float *dst, const   float *src, int n, int update_ctx);
37 int swri_resample_linear_double(ResampleContext *c,  double *dst, const  double *src, int n, int update_ctx);
38
39 #define DO_RESAMPLE_ONE 1
40
41 #define TEMPLATE_RESAMPLE_S16
42 #include "resample_template.c"
43 #undef TEMPLATE_RESAMPLE_S16
44
45 #define TEMPLATE_RESAMPLE_S32
46 #include "resample_template.c"
47 #undef TEMPLATE_RESAMPLE_S32
48
49 #define TEMPLATE_RESAMPLE_FLT
50 #include "resample_template.c"
51 #undef TEMPLATE_RESAMPLE_FLT
52
53 #define TEMPLATE_RESAMPLE_DBL
54 #include "resample_template.c"
55 #undef TEMPLATE_RESAMPLE_DBL
56
57 #undef DO_RESAMPLE_ONE
58
59 void swresample_dsp_init(ResampleContext *c)
60 {
61 #define FNIDX(fmt) (AV_SAMPLE_FMT_##fmt - AV_SAMPLE_FMT_S16P)
62     c->dsp.resample_one[FNIDX(S16P)] = (resample_one_fn) resample_one_int16;
63     c->dsp.resample_one[FNIDX(S32P)] = (resample_one_fn) resample_one_int32;
64     c->dsp.resample_one[FNIDX(FLTP)] = (resample_one_fn) resample_one_float;
65     c->dsp.resample_one[FNIDX(DBLP)] = (resample_one_fn) resample_one_double;
66
67     c->dsp.resample_common[FNIDX(S16P)] = (resample_fn) swri_resample_common_int16;
68     c->dsp.resample_common[FNIDX(S32P)] = (resample_fn) swri_resample_common_int32;
69     c->dsp.resample_common[FNIDX(FLTP)] = (resample_fn) swri_resample_common_float;
70     c->dsp.resample_common[FNIDX(DBLP)] = (resample_fn) swri_resample_common_double;
71
72     c->dsp.resample_linear[FNIDX(S16P)] = (resample_fn) swri_resample_linear_int16;
73     c->dsp.resample_linear[FNIDX(S32P)] = (resample_fn) swri_resample_linear_int32;
74     c->dsp.resample_linear[FNIDX(FLTP)] = (resample_fn) swri_resample_linear_float;
75     c->dsp.resample_linear[FNIDX(DBLP)] = (resample_fn) swri_resample_linear_double;
76
77     if (ARCH_X86) swresample_dsp_x86_init(c);
78 }