annotate resample.c @ 8871:199e9809eb5a libavcodec

some more K&R whitespace cosmetics
author diego
date Sat, 14 Feb 2009 19:39:07 +0000
parents cbeaa8c0fe4f
children 28b706b75b00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
5355
45d083bbbbe7 typo fixes
diego
parents: 4712
diff changeset
2 * samplerate conversion for both audio and video
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 7470
diff changeset
3 * Copyright (c) 2000 Fabrice Bellard
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
15 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
20 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 8629
diff changeset
23 * @file libavcodec/resample.c
5355
45d083bbbbe7 typo fixes
diego
parents: 4712
diff changeset
24 * samplerate conversion for both audio and video
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
25 */
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
26
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
27 #include "avcodec.h"
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
28 #include "audioconvert.h"
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
29 #include "opt.h"
1125
0980ae063f4e restoring OS/2 compatibility patch by ("Slavik Gnatenko" <miracle9 at newmail dot ru>)
michaelni
parents: 1106
diff changeset
30
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
31 struct AVResampleContext;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
32
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
33 static const char *context_to_name(void *ptr)
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
34 {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
35 return "audioresample";
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
36 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
37
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
38 static const AVOption options[] = {{NULL}};
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
39 static const AVClass audioresample_context_class = { "ReSampleContext", context_to_name, options };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
40
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 struct ReSampleContext {
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
42 const AVClass *av_class;
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
43 struct AVResampleContext *resample_context;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
44 short *temp[2];
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
45 int temp_len;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
46 float ratio;
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 /* channel convert */
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 int input_channels, output_channels, filter_channels;
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
49 AVAudioConvert *convert_ctx[2];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
50 enum SampleFormat sample_fmt[2]; ///< input and output sample format
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
51 unsigned sample_size[2]; ///< size of one sample in sample_fmt
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
52 short *buffer[2]; ///< buffers used for conversion to S16
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
53 unsigned buffer_size[2]; ///< sizes of allocated buffers
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 };
986e461dc072 Initial revision
glantau
parents:
diff changeset
55
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 /* n1: number of samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
57 static void stereo_to_mono(short *output, short *input, int n1)
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 short *p, *q;
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 int n = n1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
61
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 p = input;
986e461dc072 Initial revision
glantau
parents:
diff changeset
63 q = output;
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 while (n >= 4) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
65 q[0] = (p[0] + p[1]) >> 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 q[1] = (p[2] + p[3]) >> 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
67 q[2] = (p[4] + p[5]) >> 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 q[3] = (p[6] + p[7]) >> 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
69 q += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 p += 8;
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 n -= 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
73 while (n > 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 q[0] = (p[0] + p[1]) >> 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 q++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
76 p += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
77 n--;
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
80
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 /* n1: number of samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 static void mono_to_stereo(short *output, short *input, int n1)
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 short *p, *q;
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 int n = n1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 int v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
87
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 p = input;
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 q = output;
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 while (n >= 4) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 v = p[0]; q[0] = v; q[1] = v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 v = p[1]; q[2] = v; q[3] = v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 v = p[2]; q[4] = v; q[5] = v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 v = p[3]; q[6] = v; q[7] = v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 q += 8;
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 p += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 n -= 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
98 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 while (n > 0) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 v = p[0]; q[0] = v; q[1] = v;
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 q += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
102 p += 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 n--;
986e461dc072 Initial revision
glantau
parents:
diff changeset
104 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
106
986e461dc072 Initial revision
glantau
parents:
diff changeset
107 /* XXX: should use more abstract 'N' channels system */
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 static void stereo_split(short *output1, short *output2, short *input, int n)
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
111
986e461dc072 Initial revision
glantau
parents:
diff changeset
112 for(i=0;i<n;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 *output1++ = *input++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 *output2++ = *input++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
115 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
117
986e461dc072 Initial revision
glantau
parents:
diff changeset
118 static void stereo_mux(short *output, short *input1, short *input2, int n)
986e461dc072 Initial revision
glantau
parents:
diff changeset
119 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
120 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
121
986e461dc072 Initial revision
glantau
parents:
diff changeset
122 for(i=0;i<n;i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 *output++ = *input1++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
124 *output++ = *input2++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
126 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
127
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
128 static void ac3_5p1_mux(short *output, short *input1, short *input2, int n)
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
129 {
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
130 int i;
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
131 short l,r;
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
132
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
133 for(i=0;i<n;i++) {
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
134 l=*input1++;
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
135 r=*input2++;
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
136 *output++ = l; /* left */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
137 *output++ = (l/2)+(r/2); /* center */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
138 *output++ = r; /* right */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
139 *output++ = 0; /* left surround */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
140 *output++ = 0; /* right surroud */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
141 *output++ = 0; /* low freq */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
142 }
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
143 }
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
144
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
145 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
146 int output_rate, int input_rate,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
147 enum SampleFormat sample_fmt_out,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
148 enum SampleFormat sample_fmt_in,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
149 int filter_length, int log2_phase_count,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
150 int linear, double cutoff)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 ReSampleContext *s;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2522
diff changeset
153
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
154 if ( input_channels > 2)
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
155 {
6023
78b46e3f9df2 Add missing '\n' to log format text
andoma
parents: 5959
diff changeset
156 av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n");
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
157 return NULL;
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
158 }
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
159
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 s = av_mallocz(sizeof(ReSampleContext));
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 if (!s)
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
162 {
6023
78b46e3f9df2 Add missing '\n' to log format text
andoma
parents: 5959
diff changeset
163 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.\n");
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
164 return NULL;
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
165 }
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
166
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 s->ratio = (float)output_rate / (float)input_rate;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2522
diff changeset
168
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 s->input_channels = input_channels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
170 s->output_channels = output_channels;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2522
diff changeset
171
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
172 s->filter_channels = s->input_channels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 if (s->output_channels < s->filter_channels)
986e461dc072 Initial revision
glantau
parents:
diff changeset
174 s->filter_channels = s->output_channels;
986e461dc072 Initial revision
glantau
parents:
diff changeset
175
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
176 s->sample_fmt [0] = sample_fmt_in;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
177 s->sample_fmt [1] = sample_fmt_out;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
178 s->sample_size[0] = av_get_bits_per_sample_format(s->sample_fmt[0])>>3;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
179 s->sample_size[1] = av_get_bits_per_sample_format(s->sample_fmt[1])>>3;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
180
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
181 if (s->sample_fmt[0] != SAMPLE_FMT_S16) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
182 if (!(s->convert_ctx[0] = av_audio_convert_alloc(SAMPLE_FMT_S16, 1,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
183 s->sample_fmt[0], 1, NULL, 0))) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
184 av_log(s, AV_LOG_ERROR,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
185 "Cannot convert %s sample format to s16 sample format\n",
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
186 avcodec_get_sample_fmt_name(s->sample_fmt[0]));
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
187 av_free(s);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
188 return NULL;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
189 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
190 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
191
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
192 if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
193 if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1], 1,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
194 SAMPLE_FMT_S16, 1, NULL, 0))) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
195 av_log(s, AV_LOG_ERROR,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
196 "Cannot convert s16 sample format to %s sample format\n",
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
197 avcodec_get_sample_fmt_name(s->sample_fmt[1]));
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
198 av_audio_convert_free(s->convert_ctx[0]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
199 av_free(s);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
200 return NULL;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
201 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
202 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
203
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
204 /*
7470
1a93d3bbe3ee cosmetics: make all references to AC-3 capitalized and hyphenated
jbr
parents: 6023
diff changeset
205 * AC-3 output is the only case where filter_channels could be greater than 2.
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
206 * input channels can't be greater than 2, so resample the 2 channels and then
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
207 * expand to 6 channels after the resampling.
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
208 */
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
209 if(s->filter_channels>2)
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
210 s->filter_channels = 2;
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
211
4712
5c0c96d437f2 set more reasonable cutoff for audio rate conversion
michael
parents: 3947
diff changeset
212 #define TAPS 16
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
213 s->resample_context= av_resample_init(output_rate, input_rate,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
214 filter_length, log2_phase_count, linear, cutoff);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
215
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
216 s->av_class= &audioresample_context_class;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2522
diff changeset
217
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
218 return s;
986e461dc072 Initial revision
glantau
parents:
diff changeset
219 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
220
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
221 #if LIBAVCODEC_VERSION_MAJOR < 53
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
222 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
223 int output_rate, int input_rate)
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
224 {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
225 return av_audio_resample_init(output_channels, input_channels,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
226 output_rate, input_rate,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
227 SAMPLE_FMT_S16, SAMPLE_FMT_S16,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
228 TAPS, 10, 0, 0.8);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
229 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
230 #endif
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
231
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 /* resample audio. 'nb_samples' is the number of input samples */
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 /* XXX: optimize it ! */
986e461dc072 Initial revision
glantau
parents:
diff changeset
234 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples)
986e461dc072 Initial revision
glantau
parents:
diff changeset
235 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
236 int i, nb_samples1;
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
237 short *bufin[2];
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
238 short *bufout[2];
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
239 short *buftmp2[2], *buftmp3[2];
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
240 short *output_bak = NULL;
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
241 int lenout;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
242
2109
84637c6ca74e various resampling fixes
michael
parents: 2084
diff changeset
243 if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) {
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
244 /* nothing to do */
986e461dc072 Initial revision
glantau
parents:
diff changeset
245 memcpy(output, input, nb_samples * s->input_channels * sizeof(short));
986e461dc072 Initial revision
glantau
parents:
diff changeset
246 return nb_samples;
986e461dc072 Initial revision
glantau
parents:
diff changeset
247 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
248
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
249 if (s->sample_fmt[0] != SAMPLE_FMT_S16) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
250 int istride[1] = { s->sample_size[0] };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
251 int ostride[1] = { 2 };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
252 const void *ibuf[1] = { input };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
253 void *obuf[1];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
254 unsigned input_size = nb_samples*s->input_channels*s->sample_size[0];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
255
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
256 if (!s->buffer_size[0] || s->buffer_size[0] < input_size) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
257 av_free(s->buffer[0]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
258 s->buffer_size[0] = input_size;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
259 s->buffer[0] = av_malloc(s->buffer_size[0]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
260 if (!s->buffer[0]) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
261 av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n");
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
262 return 0;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
263 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
264 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
265
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
266 obuf[0] = s->buffer[0];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
267
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
268 if (av_audio_convert(s->convert_ctx[0], obuf, ostride,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
269 ibuf, istride, nb_samples*s->input_channels) < 0) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
270 av_log(s, AV_LOG_ERROR, "Audio sample format conversion failed\n");
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
271 return 0;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
272 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
273
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
274 input = s->buffer[0];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
275 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
276
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
277 lenout= 4*nb_samples * s->ratio + 16;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
278
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
279 if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
280 output_bak = output;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
281
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
282 if (!s->buffer_size[1] || s->buffer_size[1] < lenout) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
283 av_free(s->buffer[1]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
284 s->buffer_size[1] = lenout;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
285 s->buffer[1] = av_malloc(s->buffer_size[1]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
286 if (!s->buffer[1]) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
287 av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n");
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
288 return 0;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
289 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
290 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
291
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
292 output = s->buffer[1];
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
293 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
294
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
295 /* XXX: move those malloc to resample init code */
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
296 for(i=0; i<s->filter_channels; i++){
5958
ed05a3d964fa stupid code (casting of void*) found by checktree.sh
michael
parents: 5502
diff changeset
297 bufin[i]= av_malloc( (nb_samples + s->temp_len) * sizeof(short) );
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
298 memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
299 buftmp2[i] = bufin[i] + s->temp_len;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
300 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2522
diff changeset
301
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
302 /* make some zoom to avoid round pb */
5958
ed05a3d964fa stupid code (casting of void*) found by checktree.sh
michael
parents: 5502
diff changeset
303 bufout[0]= av_malloc( lenout * sizeof(short) );
ed05a3d964fa stupid code (casting of void*) found by checktree.sh
michael
parents: 5502
diff changeset
304 bufout[1]= av_malloc( lenout * sizeof(short) );
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
305
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
306 if (s->input_channels == 2 &&
986e461dc072 Initial revision
glantau
parents:
diff changeset
307 s->output_channels == 1) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
308 buftmp3[0] = output;
986e461dc072 Initial revision
glantau
parents:
diff changeset
309 stereo_to_mono(buftmp2[0], input, nb_samples);
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
310 } else if (s->output_channels >= 2 && s->input_channels == 1) {
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
311 buftmp3[0] = bufout[0];
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
312 memcpy(buftmp2[0], input, nb_samples*sizeof(short));
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
313 } else if (s->output_channels >= 2) {
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 buftmp3[0] = bufout[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
315 buftmp3[1] = bufout[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
316 stereo_split(buftmp2[0], buftmp2[1], input, nb_samples);
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 } else {
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 buftmp3[0] = output;
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
319 memcpy(buftmp2[0], input, nb_samples*sizeof(short));
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
320 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
321
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
322 nb_samples += s->temp_len;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
323
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
324 /* resample each channel */
986e461dc072 Initial revision
glantau
parents:
diff changeset
325 nb_samples1 = 0; /* avoid warning */
986e461dc072 Initial revision
glantau
parents:
diff changeset
326 for(i=0;i<s->filter_channels;i++) {
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
327 int consumed;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
328 int is_last= i+1 == s->filter_channels;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
329
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
330 nb_samples1 = av_resample(s->resample_context, buftmp3[i], bufin[i], &consumed, nb_samples, lenout, is_last);
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
331 s->temp_len= nb_samples - consumed;
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
332 s->temp[i]= av_realloc(s->temp[i], s->temp_len*sizeof(short));
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
333 memcpy(s->temp[i], bufin[i] + consumed, s->temp_len*sizeof(short));
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
334 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
335
986e461dc072 Initial revision
glantau
parents:
diff changeset
336 if (s->output_channels == 2 && s->input_channels == 1) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
337 mono_to_stereo(output, buftmp3[0], nb_samples1);
986e461dc072 Initial revision
glantau
parents:
diff changeset
338 } else if (s->output_channels == 2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
339 stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
1408
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
340 } else if (s->output_channels == 6) {
4d67eb341a0c AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
michaelni
parents: 1128
diff changeset
341 ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
342 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
343
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
344 if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
345 int istride[1] = { 2 };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
346 int ostride[1] = { s->sample_size[1] };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
347 const void *ibuf[1] = { output };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
348 void *obuf[1] = { output_bak };
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
349
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
350 if (av_audio_convert(s->convert_ctx[1], obuf, ostride,
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
351 ibuf, istride, nb_samples1*s->output_channels) < 0) {
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
352 av_log(s, AV_LOG_ERROR, "Audio sample format convertion failed\n");
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
353 return 0;
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
354 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
355 }
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
356
2084
michael
parents: 2082
diff changeset
357 for(i=0; i<s->filter_channels; i++)
michael
parents: 2082
diff changeset
358 av_free(bufin[i]);
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
359
396
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 373
diff changeset
360 av_free(bufout[0]);
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 373
diff changeset
361 av_free(bufout[1]);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
362 return nb_samples1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
363 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
364
986e461dc072 Initial revision
glantau
parents:
diff changeset
365 void audio_resample_close(ReSampleContext *s)
986e461dc072 Initial revision
glantau
parents:
diff changeset
366 {
2082
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
367 av_resample_close(s->resample_context);
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
368 av_freep(&s->temp[0]);
3dc9bbe1b152 polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample filters
michael
parents: 1598
diff changeset
369 av_freep(&s->temp[1]);
8806
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
370 av_freep(&s->buffer[0]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
371 av_freep(&s->buffer[1]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
372 av_audio_convert_free(s->convert_ctx[0]);
cbeaa8c0fe4f extend resampling API, add S16 internal conversion
bcoudurier
parents: 8718
diff changeset
373 av_audio_convert_free(s->convert_ctx[1]);
396
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 373
diff changeset
374 av_free(s);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
375 }