1 /*
2 * Copyright (c) 2011 Stefano Sabatini
3 * Copyright (c) 2011 Mina Nagy Zaki
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 * resampling audio filter
25 */
26
36
46
48 {
51
54 if (!aresample->
swr) {
57 }
58
59 if (opts) {
61
65 }
67 }
72 }
73
75 {
78 }
79
81 {
86
89
96
100
101 if(out_rate > 0) {
102 int ratelist[] = { out_rate, -1 };
104 } else {
106 }
107 if (!out_samplerates) {
110 }
111
113
115 int formatlist[] = { out_format, -1 };
117 } else
120
121 if(out_layout) {
122 int64_t layout_list[] = { out_layout, -1 };
124 } else
127
128 return 0;
129 }
130
131
133 {
138 int out_rate;
139 uint64_t out_layout;
141 char inchl_buf[128], outchl_buf[128];
142
146 0, ctx);
153
155 if (ret < 0)
157
162
166
168
171
175 return 0;
176 }
177
179 {
182 int64_t delay;
183 int n_out = n_in * aresample->
ratio + 32;
187
189 if (delay > 0)
191
193
194 if(!outsamplesref)
196
202
208 } else {
210 }
213 if (n_out <= 0) {
216 return 0;
217 }
218
219 aresample->
more_data = outsamplesref->
nb_samples == n_out;
// Indicate that there is probably more data in our buffers
220
222
227 }
228
230 {
235 int n_out = 4096;
237
239 *outsamplesref_ret = outsamplesref;
240 if (!outsamplesref)
242
245
247 if (n_out <= 0) {
250 }
251
254
256
257 return 0;
258 }
259
261 {
265
266 // First try to get data from the internal buffers
269
270 if (
flush_frame(outlink, 0, &outsamplesref) >= 0) {
272 }
273 }
275
276 // Second request more data from the input
278 do{
281
282 // Third if we hit the end flush
285
286 if ((ret =
flush_frame(outlink, 1, &outsamplesref)) < 0)
288
290 }
292 }
293
295 {
297 }
298
300 {
303 }
304
305 #define OFFSET(x) offsetof(AResampleContext, x)
306 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
307
311 };
312
320 };
321
323 {
327 },
329 };
330
332 {
337 },
339 };
340
348 .priv_class = &aresample_class,
349 .
inputs = aresample_inputs,
351 };