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
40 NULL
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
72 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
73 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX,
FLAGS },
80 {NULL},
81 };
82
84
86 {
91
92 if (!args1) {
96 }
97
98 /* parse expressions */
99 buf = args1;
100 i = 0;
103 NULL, NULL, NULL, NULL, 0, ctx);
104 if (ret < 0)
106 i++;
107 }
109
113 if (ret < 0)
115
119 "Mismatch between the specified number of channels '%d' "
120 "and the number of channels '%d' in the specified channel layout '%s'\n",
124 }
125 } else {
126 /* guess channel layout from nb expressions/channels */
133 }
134 }
135
138
141 int64_t us = -1;
145 }
146 eval->
duration = (double)us / 1000000;
147 }
149
153 }
154
156 {
158 int i;
159
160 for (i = 0; i < 8; i++) {
162 eval->
expr[i] = NULL;
163 }
167 }
168
170 {
173
176
178
180
182 "sample_rate:%d chlayout:%s duration:%f\n",
184
185 return 0;
186 }
187
189 {
192 int64_t chlayouts[] = { eval->
chlayout, -1 };
194
198
199 return 0;
200 }
201
203 {
206 int i, j;
208
211
213 if (!samplesref)
215
216 /* evaluate expression for each single sample and for each channel */
217 for (i = 0; i < eval->
nb_samples; i++, eval->
n++) {
220
224 }
225 }
226
227 samplesref->
pts = eval->
pts;
230
232 }
233
235 {
240 },
241 { NULL }
242 };
243
247
254 .priv_class = &aevalsrc_class,
255 };