1 /*
2 * Copyright (c) 2011 Stefano Sabatini
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * eval audio source
24 */
25
35
37 "n", ///< number of frame
38 "t", ///< timestamp expressed in seconds
39 "s", ///< sample rate
41 };
42
48 };
49
60 int nb_samples;
///< number of samples per requested frame
66
67 #define OFFSET(x) offsetof(EvalContext, x)
68 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
69
80 };
81
83
85 {
88 char *expr, *buf, *bufptr;
89 int ret, i;
90
91 eval->
class = &aevalsrc_class;
93
94 if (!args1) {
98 }
99
100 /* parse expressions */
101 buf = args1;
102 i = 0;
103 while (expr =
av_strtok(buf,
":", &bufptr)) {
106 if (ret < 0)
108 i++;
109 if (bufptr && *bufptr == ':') { /* found last expression */
110 bufptr++;
111 break;
112 }
114 }
116
119
121 int n;
123 if (ret < 0)
125
129 "Mismatch between the specified number of channels '%d' "
130 "and the number of channels '%d' in the specified channel layout '%s'\n",
134 }
135 } else {
136 /* guess channel layout from nb expressions/channels */
143 }
144 }
145
148
151 int64_t us = -1;
155 }
156 eval->
duration = (double)us / 1000000;
157 }
159
162 return ret;
163 }
164
166 {
168 int i;
169
170 for (i = 0; i < 8; i++) {
173 }
177 }
178
180 {
182 char buf[128];
183
186
188
190
192 "sample_rate:%d chlayout:%s duration:%f\n",
194
195 return 0;
196 }
197
199 {
202 int64_t chlayouts[] = { eval->
chlayout, -1 };
204
208
209 return 0;
210 }
211
213 {
216 int i, j;
218
221
223
224 /* evaluate expression for each single sample and for each channel */
225 for (i = 0; i < eval->
nb_samples; i++, eval->
n++) {
228
232 }
233 }
234
235 samplesref->
pts = eval->
pts;
236 samplesref->
pos = -1;
239
241
242 return 0;
243 }
244
246 {
251 },
253 };
254
258
265 .priv_class = &aevalsrc_class,
266 };