FFmpeg
aeval.c
Go to the documentation of this file.
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 
26 #include "config_components.h"
27 
28 #include "libavutil/avstring.h"
30 #include "libavutil/eval.h"
31 #include "libavutil/mem.h"
32 #include "libavutil/opt.h"
33 #include "avfilter.h"
34 #include "audio.h"
35 #include "filters.h"
36 #include "formats.h"
37 
38 static const char * const var_names[] = {
39  "ch", ///< the value of the current channel
40  "n", ///< number of frame
41  "nb_in_channels",
42  "nb_out_channels",
43  "t", ///< timestamp expressed in seconds
44  "s", ///< sample rate
45  NULL
46 };
47 
48 enum var_name {
56 };
57 
58 typedef struct EvalContext {
59  const AVClass *class;
63  char *chlayout_str;
64  int nb_channels; ///< number of output channels
65  int nb_in_channels; ///< number of input channels
66  int same_chlayout; ///< set output as input channel layout
69  char *exprs;
70  int nb_samples; ///< number of samples per requested frame
72  uint64_t n;
74  double *channel_values;
75 } EvalContext;
76 
77 static double val(void *priv, double ch)
78 {
79  EvalContext *eval = priv;
80  return eval->channel_values[FFMIN((int)ch, eval->nb_in_channels-1)];
81 }
82 
83 static double (* const aeval_func1[])(void *, double) = { val, NULL };
84 static const char * const aeval_func1_names[] = { "val", NULL };
85 
86 #define OFFSET(x) offsetof(EvalContext, x)
87 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
88 
89 static const AVOption aevalsrc_options[]= {
90  { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS },
91  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
92  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
93  { "sample_rate", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
94  { "s", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
95  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
96  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
97  { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
98  { "c", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
99  { NULL }
100 };
101 
102 AVFILTER_DEFINE_CLASS(aevalsrc);
103 
105  int expected_nb_channels)
106 {
107  EvalContext *eval = ctx->priv;
108  char *args1 = av_strdup(eval->exprs);
109  char *expr, *last_expr = NULL, *buf;
110  double (* const *func1)(void *, double) = NULL;
111  const char * const *func1_names = NULL;
112  int i, ret = 0;
113 
114  if (!args1)
115  return AVERROR(ENOMEM);
116 
117  if (!eval->exprs) {
118  av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n");
119  return AVERROR(EINVAL);
120  }
121 
122  if (!strcmp(ctx->filter->name, "aeval")) {
123  func1 = aeval_func1;
125  }
126 
127 #define ADD_EXPRESSION(expr_) do { \
128  ret = av_dynarray_add_nofree(&eval->expr, \
129  &eval->nb_channels, NULL); \
130  if (ret < 0) \
131  goto end; \
132  eval->expr[eval->nb_channels-1] = NULL; \
133  ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
134  var_names, func1_names, func1, \
135  NULL, NULL, 0, ctx); \
136  if (ret < 0) \
137  goto end; \
138  } while (0)
139 
140  /* reset expressions */
141  for (i = 0; i < eval->nb_channels; i++) {
142  av_expr_free(eval->expr[i]);
143  eval->expr[i] = NULL;
144  }
145  av_freep(&eval->expr);
146  eval->nb_channels = 0;
147 
148  buf = args1;
149  while (expr = av_strtok(buf, "|", &buf)) {
150  ADD_EXPRESSION(expr);
151  last_expr = expr;
152  }
153 
154  if (expected_nb_channels > eval->nb_channels)
155  for (i = eval->nb_channels; i < expected_nb_channels; i++)
156  ADD_EXPRESSION(last_expr);
157 
158  if (expected_nb_channels > 0 && eval->nb_channels != expected_nb_channels) {
160  "Mismatch between the specified number of channel expressions '%d' "
161  "and the number of expected output channels '%d' for the specified channel layout\n",
162  eval->nb_channels, expected_nb_channels);
163  ret = AVERROR(EINVAL);
164  goto end;
165  }
166 
167 end:
168  av_free(args1);
169  return ret;
170 }
171 
173 {
174  EvalContext *eval = ctx->priv;
175  int ret = 0;
176 
177  if (eval->chlayout_str) {
178  if (!strcmp(eval->chlayout_str, "same") && !strcmp(ctx->filter->name, "aeval")) {
179  eval->same_chlayout = 1;
180  } else {
182  if (ret < 0)
183  return ret;
184 
186  if (ret < 0)
187  return ret;
188  }
189  } else {
190  /* guess channel layout from nb expressions/channels */
191  if ((ret = parse_channel_expressions(ctx, -1)) < 0)
192  return ret;
193 
195  if (eval->nb_channels <= 0) {
196  av_log(ctx, AV_LOG_ERROR, "Invalid number of channels '%d' provided\n",
197  eval->nb_channels);
198  return AVERROR(EINVAL);
199  }
200  }
201 
202  if (eval->sample_rate_str)
203  if ((ret = ff_parse_sample_rate(&eval->sample_rate, eval->sample_rate_str, ctx)))
204  return ret;
205  eval->n = 0;
206 
207  return ret;
208 }
209 
211 {
212  EvalContext *eval = ctx->priv;
213  int i;
214 
215  for (i = 0; i < eval->nb_channels; i++) {
216  av_expr_free(eval->expr[i]);
217  eval->expr[i] = NULL;
218  }
219  av_freep(&eval->expr);
220  av_freep(&eval->channel_values);
222 }
223 
224 static int config_props(AVFilterLink *outlink)
225 {
226  EvalContext *eval = outlink->src->priv;
227  char buf[128];
228 
229  outlink->time_base = (AVRational){1, eval->sample_rate};
230  outlink->sample_rate = eval->sample_rate;
231 
232  eval->var_values[VAR_S] = eval->sample_rate;
235 
236  av_channel_layout_describe(&eval->chlayout, buf, sizeof(buf));
237 
238  av_log(outlink->src, AV_LOG_VERBOSE,
239  "sample_rate:%d chlayout:%s duration:%"PRId64"\n",
240  eval->sample_rate, buf, eval->duration);
241 
242  return 0;
243 }
244 
246  AVFilterFormatsConfig **cfg_in,
247  AVFilterFormatsConfig **cfg_out)
248 {
249  const EvalContext *eval = ctx->priv;
251  AVChannelLayout chlayouts[] = { eval->chlayout.nb_channels ? eval->chlayout : FF_COUNT2LAYOUT(eval->nb_channels), { 0 } };
252  int sample_rates[] = { eval->sample_rate, -1 };
253  int ret;
254 
256  if (ret < 0)
257  return ret;
258 
259  ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, chlayouts);
260  if (ret < 0)
261  return ret;
262 
263  return ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
264 }
265 
267 {
268  AVFilterLink *outlink = ctx->outputs[0];
269  EvalContext *eval = outlink->src->priv;
270  AVFrame *samplesref;
271  int i, j;
272  int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate);
273  int nb_samples;
274 
275  if (!ff_outlink_frame_wanted(outlink))
276  return FFERROR_NOT_READY;
277 
278  if (eval->duration >= 0 && t >= eval->duration) {
279  ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
280  return 0;
281  }
282 
283  if (eval->duration >= 0) {
284  nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
285  if (!nb_samples) {
286  ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
287  return 0;
288  }
289  } else {
290  nb_samples = eval->nb_samples;
291  }
292  samplesref = ff_get_audio_buffer(outlink, nb_samples);
293  if (!samplesref)
294  return AVERROR(ENOMEM);
295 
296  /* evaluate expression for each single sample and for each channel */
297  for (i = 0; i < nb_samples; i++, eval->n++) {
298  eval->var_values[VAR_N] = eval->n;
299  eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate;
300 
301  for (j = 0; j < eval->nb_channels; j++) {
302  *((double *) samplesref->extended_data[j] + i) =
303  av_expr_eval(eval->expr[j], eval->var_values, NULL);
304  }
305  }
306 
307  samplesref->pts = eval->pts;
308  samplesref->sample_rate = eval->sample_rate;
309  eval->pts += nb_samples;
310 
311  return ff_filter_frame(outlink, samplesref);
312 }
313 
314 #if CONFIG_AEVALSRC_FILTER
315 static const AVFilterPad aevalsrc_outputs[] = {
316  {
317  .name = "default",
318  .type = AVMEDIA_TYPE_AUDIO,
319  .config_props = config_props,
320  },
321 };
322 
323 const AVFilter ff_asrc_aevalsrc = {
324  .name = "aevalsrc",
325  .description = NULL_IF_CONFIG_SMALL("Generate an audio signal generated by an expression."),
326  .init = init,
327  .uninit = uninit,
328  .activate = activate,
329  .priv_size = sizeof(EvalContext),
330  .inputs = NULL,
331  FILTER_OUTPUTS(aevalsrc_outputs),
333  .priv_class = &aevalsrc_class,
334 };
335 
336 #endif /* CONFIG_AEVALSRC_FILTER */
337 
338 #define OFFSET(x) offsetof(EvalContext, x)
339 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
340 
341 static const AVOption aeval_options[]= {
342  { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS },
343  { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
344  { "c", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
345  { NULL }
346 };
347 
348 AVFILTER_DEFINE_CLASS(aeval);
349 
351  AVFilterFormatsConfig **cfg_in,
352  AVFilterFormatsConfig **cfg_out)
353 {
355  const EvalContext *eval = ctx->priv;
356  static const enum AVSampleFormat sample_fmts[] = {
358  };
359  int ret;
360 
361  // inlink supports any channel layout
363  if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts)) < 0)
364  return ret;
365 
366  if (!eval->same_chlayout) {
367  // outlink supports only requested output channel layout
368  layouts = NULL;
370  return ret;
371  if ((ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts)) < 0)
372  return ret;
373  }
374 
375  if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts)) < 0)
376  return ret;
377 
378  return 0;
379 }
380 
381 static int aeval_config_output(AVFilterLink *outlink)
382 {
383  AVFilterContext *ctx = outlink->src;
384  EvalContext *eval = ctx->priv;
385  AVFilterLink *inlink = ctx->inputs[0];
386  int ret;
387 
388  if (eval->same_chlayout) {
389  if ((ret = av_channel_layout_copy(&eval->chlayout, &inlink->ch_layout)) < 0)
390  return ret;
391 
392  if ((ret = parse_channel_expressions(ctx, inlink->ch_layout.nb_channels)) < 0)
393  return ret;
394  }
395 
396  eval->n = 0;
397  eval->nb_in_channels = eval->var_values[VAR_NB_IN_CHANNELS] = inlink->ch_layout.nb_channels;
399  eval->var_values[VAR_S] = inlink->sample_rate;
400  eval->var_values[VAR_T] = NAN;
401 
403  inlink->ch_layout.nb_channels, sizeof(*eval->channel_values));
404  if (!eval->channel_values)
405  return AVERROR(ENOMEM);
406 
407  return 0;
408 }
409 
411 {
412  EvalContext *eval = inlink->dst->priv;
413  AVFilterLink *outlink = inlink->dst->outputs[0];
414  int nb_samples = in->nb_samples;
415  AVFrame *out;
416  double t0;
417  int i, j;
418 
419  out = ff_get_audio_buffer(outlink, nb_samples);
420  if (!out) {
421  av_frame_free(&in);
422  return AVERROR(ENOMEM);
423  }
425 
426  t0 = TS2T(in->pts, inlink->time_base);
427 
428  /* evaluate expression for each single sample and for each channel */
429  for (i = 0; i < nb_samples; i++, eval->n++) {
430  eval->var_values[VAR_N] = eval->n;
431  eval->var_values[VAR_T] = t0 + i * (double)1/inlink->sample_rate;
432 
433  for (j = 0; j < inlink->ch_layout.nb_channels; j++)
434  eval->channel_values[j] = *((double *) in->extended_data[j] + i);
435 
436  for (j = 0; j < outlink->ch_layout.nb_channels; j++) {
437  eval->var_values[VAR_CH] = j;
438  *((double *) out->extended_data[j] + i) =
439  av_expr_eval(eval->expr[j], eval->var_values, eval);
440  }
441  }
442 
443  av_frame_free(&in);
444  return ff_filter_frame(outlink, out);
445 }
446 
447 #if CONFIG_AEVAL_FILTER
448 
449 static const AVFilterPad aeval_inputs[] = {
450  {
451  .name = "default",
452  .type = AVMEDIA_TYPE_AUDIO,
453  .filter_frame = filter_frame,
454  },
455 };
456 
457 static const AVFilterPad aeval_outputs[] = {
458  {
459  .name = "default",
460  .type = AVMEDIA_TYPE_AUDIO,
461  .config_props = aeval_config_output,
462  },
463 };
464 
465 const AVFilter ff_af_aeval = {
466  .name = "aeval",
467  .description = NULL_IF_CONFIG_SMALL("Filter audio signal according to a specified expression."),
468  .init = init,
469  .uninit = uninit,
470  .priv_size = sizeof(EvalContext),
471  FILTER_INPUTS(aeval_inputs),
472  FILTER_OUTPUTS(aeval_outputs),
474  .priv_class = &aeval_class,
476 };
477 
478 #endif /* CONFIG_AEVAL_FILTER */
EvalContext::expr
AVExpr ** expr
Definition: aeval.c:68
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:98
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
var_name
var_name
Definition: noise.c:47
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1061
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:673
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:335
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
EvalContext::duration
int64_t duration
Definition: aeval.c:71
int64_t
long long int64_t
Definition: coverity.c:34
aeval_query_formats
static int aeval_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: aeval.c:350
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:621
init
static av_cold int init(AVFilterContext *ctx)
Definition: aeval.c:172
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
sample_rates
static const int sample_rates[]
Definition: dcaenc.h:34
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:403
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:515
ADD_EXPRESSION
#define ADD_EXPRESSION(expr_)
AVOption
AVOption.
Definition: opt.h:429
FLAGS
#define FLAGS
Definition: aeval.c:339
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition: opt.h:319
ff_set_common_channel_layouts_from_list2
int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const AVChannelLayout *fmts)
Definition: formats.c:920
aeval_func1_names
static const char *const aeval_func1_names[]
Definition: aeval.c:84
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
config_props
static int config_props(AVFilterLink *outlink)
Definition: aeval.c:224
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:328
EvalContext::exprs
char * exprs
Definition: aeval.c:69
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: aeval.c:210
formats.h
VAR_T
@ VAR_T
Definition: aeval.c:53
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
EvalContext::same_chlayout
int same_chlayout
set output as input channel layout
Definition: aeval.c:66
val
static double val(void *priv, double ch)
Definition: aeval.c:77
func1_names
static const char *const func1_names[]
Definition: vf_rotate.c:188
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:358
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
EvalContext::var_values
double var_values[VAR_VARS_NB]
Definition: aeval.c:73
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
duration
int64_t duration
Definition: movenc.c:65
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:652
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:424
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:178
filters.h
ff_set_common_samplerates_from_list2
int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *samplerates)
Definition: formats.c:944
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:792
AVExpr
Definition: eval.c:158
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NAN
#define NAN
Definition: mathematics.h:115
ff_parse_channel_layout
int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
Definition: audio.c:123
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:32
aevalsrc_options
static const AVOption aevalsrc_options[]
Definition: aeval.c:89
ff_parse_sample_rate
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
Definition: audio.c:111
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:726
aeval_config_output
static int aeval_config_output(AVFilterLink *outlink)
Definition: aeval.c:381
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_af_aeval
const AVFilter ff_af_aeval
VAR_CH
@ VAR_CH
Definition: aeval.c:49
double
double
Definition: af_crystalizer.c:132
EvalContext
Definition: aeval.c:58
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:521
EvalContext::nb_in_channels
int nb_in_channels
number of input channels
Definition: aeval.c:65
OFFSET
#define OFFSET(x)
Definition: aeval.c:338
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:111
eval.h
aeval_options
static const AVOption aeval_options[]
Definition: aeval.c:341
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:318
EvalContext::pts
int64_t pts
Definition: aeval.c:67
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:602
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
EvalContext::nb_channels
int nb_channels
number of output channels
Definition: aeval.c:64
VAR_VARS_NB
@ VAR_VARS_NB
Definition: aeval.c:55
TS2T
#define TS2T(ts, tb)
Definition: filters.h:278
aeval_func1
static double(*const aeval_func1[])(void *, double)
Definition: aeval.c:83
VAR_NB_IN_CHANNELS
@ VAR_NB_IN_CHANNELS
Definition: aeval.c:51
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:182
av_channel_layout_default
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
Definition: channel_layout.c:838
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:483
func1
static double(*const func1[])(void *, double)
Definition: vf_rotate.c:182
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:464
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
AVFilter
Filter definition.
Definition: avfilter.h:201
EvalContext::sample_rate_str
char * sample_rate_str
Definition: aeval.c:60
ret
ret
Definition: filter_design.txt:187
EvalContext::chlayout_str
char * chlayout_str
Definition: aeval.c:63
FF_COUNT2LAYOUT
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(aevalsrc)
ff_set_common_formats_from_list2
int ff_set_common_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *fmts)
Definition: formats.c:1016
var_names
static const char *const var_names[]
Definition: aeval.c:38
channel_layout.h
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: aeval.c:410
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:441
VAR_NB_OUT_CHANNELS
@ VAR_NB_OUT_CHANNELS
Definition: aeval.c:52
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
activate
static int activate(AVFilterContext *ctx)
Definition: aeval.c:266
VAR_N
@ VAR_N
Definition: aeval.c:50
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:448
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:272
parse_channel_expressions
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
Definition: aeval.c:104
mem.h
audio.h
EvalContext::n
uint64_t n
Definition: aeval.c:72
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:112
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
EvalContext::sample_rate
int sample_rate
Definition: aeval.c:61
ff_asrc_aevalsrc
const AVFilter ff_asrc_aevalsrc
VAR_S
@ VAR_S
Definition: aeval.c:54
EvalContext::channel_values
double * channel_values
Definition: aeval.c:74
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: aeval.c:245
EvalContext::chlayout
AVChannelLayout chlayout
Definition: aeval.c:62
EvalContext::nb_samples
int nb_samples
number of samples per requested frame
Definition: aeval.c:70