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/opt.h"
32 #include "libavutil/parseutils.h"
33 #include "avfilter.h"
34 #include "audio.h"
35 #include "filters.h"
36 #include "formats.h"
37 #include "internal.h"
38 
39 static const char * const var_names[] = {
40  "ch", ///< the value of the current channel
41  "n", ///< number of frame
42  "nb_in_channels",
43  "nb_out_channels",
44  "t", ///< timestamp expressed in seconds
45  "s", ///< sample rate
46  NULL
47 };
48 
49 enum var_name {
57 };
58 
59 typedef struct EvalContext {
60  const AVClass *class;
64  char *chlayout_str;
65  int nb_channels; ///< number of output channels
66  int nb_in_channels; ///< number of input channels
67  int same_chlayout; ///< set output as input channel layout
70  char *exprs;
71  int nb_samples; ///< number of samples per requested frame
73  uint64_t n;
75  double *channel_values;
76 } EvalContext;
77 
78 static double val(void *priv, double ch)
79 {
80  EvalContext *eval = priv;
81  return eval->channel_values[FFMIN((int)ch, eval->nb_in_channels-1)];
82 }
83 
84 static double (* const aeval_func1[])(void *, double) = { val, NULL };
85 static const char * const aeval_func1_names[] = { "val", NULL };
86 
87 #define OFFSET(x) offsetof(EvalContext, x)
88 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
89 
90 static const AVOption aevalsrc_options[]= {
91  { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS },
92  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
93  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
94  { "sample_rate", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
95  { "s", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
96  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
97  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
98  { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
99  { "c", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
100  { NULL }
101 };
102 
103 AVFILTER_DEFINE_CLASS(aevalsrc);
104 
106  int expected_nb_channels)
107 {
108  EvalContext *eval = ctx->priv;
109  char *args1 = av_strdup(eval->exprs);
110  char *expr, *last_expr = NULL, *buf;
111  double (* const *func1)(void *, double) = NULL;
112  const char * const *func1_names = NULL;
113  int i, ret = 0;
114 
115  if (!args1)
116  return AVERROR(ENOMEM);
117 
118  if (!eval->exprs) {
119  av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n");
120  return AVERROR(EINVAL);
121  }
122 
123  if (!strcmp(ctx->filter->name, "aeval")) {
124  func1 = aeval_func1;
126  }
127 
128 #define ADD_EXPRESSION(expr_) do { \
129  ret = av_dynarray_add_nofree(&eval->expr, \
130  &eval->nb_channels, NULL); \
131  if (ret < 0) \
132  goto end; \
133  eval->expr[eval->nb_channels-1] = NULL; \
134  ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
135  var_names, func1_names, func1, \
136  NULL, NULL, 0, ctx); \
137  if (ret < 0) \
138  goto end; \
139  } while (0)
140 
141  /* reset expressions */
142  for (i = 0; i < eval->nb_channels; i++) {
143  av_expr_free(eval->expr[i]);
144  eval->expr[i] = NULL;
145  }
146  av_freep(&eval->expr);
147  eval->nb_channels = 0;
148 
149  buf = args1;
150  while (expr = av_strtok(buf, "|", &buf)) {
151  ADD_EXPRESSION(expr);
152  last_expr = expr;
153  }
154 
155  if (expected_nb_channels > eval->nb_channels)
156  for (i = eval->nb_channels; i < expected_nb_channels; i++)
157  ADD_EXPRESSION(last_expr);
158 
159  if (expected_nb_channels > 0 && eval->nb_channels != expected_nb_channels) {
161  "Mismatch between the specified number of channel expressions '%d' "
162  "and the number of expected output channels '%d' for the specified channel layout\n",
163  eval->nb_channels, expected_nb_channels);
164  ret = AVERROR(EINVAL);
165  goto end;
166  }
167 
168 end:
169  av_free(args1);
170  return ret;
171 }
172 
174 {
175  EvalContext *eval = ctx->priv;
176  int ret = 0;
177 
178  if (eval->chlayout_str) {
179  if (!strcmp(eval->chlayout_str, "same") && !strcmp(ctx->filter->name, "aeval")) {
180  eval->same_chlayout = 1;
181  } else {
183  if (ret < 0)
184  return ret;
185 
187  if (ret < 0)
188  return ret;
189  }
190  } else {
191  /* guess channel layout from nb expressions/channels */
192  if ((ret = parse_channel_expressions(ctx, -1)) < 0)
193  return ret;
194 
196  if (eval->nb_channels <= 0) {
197  av_log(ctx, AV_LOG_ERROR, "Invalid number of channels '%d' provided\n",
198  eval->nb_channels);
199  return AVERROR(EINVAL);
200  }
201  }
202 
203  if (eval->sample_rate_str)
204  if ((ret = ff_parse_sample_rate(&eval->sample_rate, eval->sample_rate_str, ctx)))
205  return ret;
206  eval->n = 0;
207 
208  return ret;
209 }
210 
212 {
213  EvalContext *eval = ctx->priv;
214  int i;
215 
216  for (i = 0; i < eval->nb_channels; i++) {
217  av_expr_free(eval->expr[i]);
218  eval->expr[i] = NULL;
219  }
220  av_freep(&eval->expr);
221  av_freep(&eval->channel_values);
223 }
224 
225 static int config_props(AVFilterLink *outlink)
226 {
227  EvalContext *eval = outlink->src->priv;
228  char buf[128];
229 
230  outlink->time_base = (AVRational){1, eval->sample_rate};
231  outlink->sample_rate = eval->sample_rate;
232 
233  eval->var_values[VAR_S] = eval->sample_rate;
236 
237  av_channel_layout_describe(&eval->chlayout, buf, sizeof(buf));
238 
239  av_log(outlink->src, AV_LOG_VERBOSE,
240  "sample_rate:%d chlayout:%s duration:%"PRId64"\n",
241  eval->sample_rate, buf, eval->duration);
242 
243  return 0;
244 }
245 
247 {
248  EvalContext *eval = ctx->priv;
250  AVChannelLayout chlayouts[] = { eval->chlayout.nb_channels ? eval->chlayout : FF_COUNT2LAYOUT(eval->nb_channels), { 0 } };
251  int sample_rates[] = { eval->sample_rate, -1 };
252  int ret;
253 
255  if (ret < 0)
256  return ret;
257 
259  if (ret < 0)
260  return ret;
261 
263 }
264 
266 {
267  AVFilterLink *outlink = ctx->outputs[0];
268  EvalContext *eval = outlink->src->priv;
269  AVFrame *samplesref;
270  int i, j;
271  int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate);
272  int nb_samples;
273 
274  if (!ff_outlink_frame_wanted(outlink))
275  return FFERROR_NOT_READY;
276 
277  if (eval->duration >= 0 && t >= eval->duration) {
278  ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
279  return 0;
280  }
281 
282  if (eval->duration >= 0) {
283  nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
284  if (!nb_samples) {
285  ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
286  return 0;
287  }
288  } else {
289  nb_samples = eval->nb_samples;
290  }
291  samplesref = ff_get_audio_buffer(outlink, nb_samples);
292  if (!samplesref)
293  return AVERROR(ENOMEM);
294 
295  /* evaluate expression for each single sample and for each channel */
296  for (i = 0; i < nb_samples; i++, eval->n++) {
297  eval->var_values[VAR_N] = eval->n;
298  eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate;
299 
300  for (j = 0; j < eval->nb_channels; j++) {
301  *((double *) samplesref->extended_data[j] + i) =
302  av_expr_eval(eval->expr[j], eval->var_values, NULL);
303  }
304  }
305 
306  samplesref->pts = eval->pts;
307  samplesref->sample_rate = eval->sample_rate;
308  eval->pts += nb_samples;
309 
310  return ff_filter_frame(outlink, samplesref);
311 }
312 
313 #if CONFIG_AEVALSRC_FILTER
314 static const AVFilterPad aevalsrc_outputs[] = {
315  {
316  .name = "default",
317  .type = AVMEDIA_TYPE_AUDIO,
318  .config_props = config_props,
319  },
320 };
321 
322 const AVFilter ff_asrc_aevalsrc = {
323  .name = "aevalsrc",
324  .description = NULL_IF_CONFIG_SMALL("Generate an audio signal generated by an expression."),
325  .init = init,
326  .uninit = uninit,
327  .activate = activate,
328  .priv_size = sizeof(EvalContext),
329  .inputs = NULL,
330  FILTER_OUTPUTS(aevalsrc_outputs),
332  .priv_class = &aevalsrc_class,
333 };
334 
335 #endif /* CONFIG_AEVALSRC_FILTER */
336 
337 #define OFFSET(x) offsetof(EvalContext, x)
338 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
339 
340 static const AVOption aeval_options[]= {
341  { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS },
342  { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
343  { "c", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
344  { NULL }
345 };
346 
347 AVFILTER_DEFINE_CLASS(aeval);
348 
350 {
352  AVFilterLink *inlink = ctx->inputs[0];
353  AVFilterLink *outlink = ctx->outputs[0];
354  EvalContext *eval = ctx->priv;
355  static const enum AVSampleFormat sample_fmts[] = {
357  };
358  int ret;
359 
360  // inlink supports any channel layout
362  if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0)
363  return ret;
364 
365  if (eval->same_chlayout) {
367  return ret;
368  } else {
369  // outlink supports only requested output channel layout
370  layouts = NULL;
372  return ret;
373  if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0)
374  return ret;
375  }
376 
378  return ret;
379 
381 }
382 
383 static int aeval_config_output(AVFilterLink *outlink)
384 {
385  AVFilterContext *ctx = outlink->src;
386  EvalContext *eval = ctx->priv;
387  AVFilterLink *inlink = ctx->inputs[0];
388  int ret;
389 
390  if (eval->same_chlayout) {
391  if ((ret = av_channel_layout_copy(&eval->chlayout, &inlink->ch_layout)) < 0)
392  return ret;
393 
394  if ((ret = parse_channel_expressions(ctx, inlink->ch_layout.nb_channels)) < 0)
395  return ret;
396  }
397 
398  eval->n = 0;
399  eval->nb_in_channels = eval->var_values[VAR_NB_IN_CHANNELS] = inlink->ch_layout.nb_channels;
401  eval->var_values[VAR_S] = inlink->sample_rate;
402  eval->var_values[VAR_T] = NAN;
403 
405  inlink->ch_layout.nb_channels, sizeof(*eval->channel_values));
406  if (!eval->channel_values)
407  return AVERROR(ENOMEM);
408 
409  return 0;
410 }
411 
413 {
414  EvalContext *eval = inlink->dst->priv;
415  AVFilterLink *outlink = inlink->dst->outputs[0];
416  int nb_samples = in->nb_samples;
417  AVFrame *out;
418  double t0;
419  int i, j;
420 
421  out = ff_get_audio_buffer(outlink, nb_samples);
422  if (!out) {
423  av_frame_free(&in);
424  return AVERROR(ENOMEM);
425  }
427 
428  t0 = TS2T(in->pts, inlink->time_base);
429 
430  /* evaluate expression for each single sample and for each channel */
431  for (i = 0; i < nb_samples; i++, eval->n++) {
432  eval->var_values[VAR_N] = eval->n;
433  eval->var_values[VAR_T] = t0 + i * (double)1/inlink->sample_rate;
434 
435  for (j = 0; j < inlink->ch_layout.nb_channels; j++)
436  eval->channel_values[j] = *((double *) in->extended_data[j] + i);
437 
438  for (j = 0; j < outlink->ch_layout.nb_channels; j++) {
439  eval->var_values[VAR_CH] = j;
440  *((double *) out->extended_data[j] + i) =
441  av_expr_eval(eval->expr[j], eval->var_values, eval);
442  }
443  }
444 
445  av_frame_free(&in);
446  return ff_filter_frame(outlink, out);
447 }
448 
449 #if CONFIG_AEVAL_FILTER
450 
451 static const AVFilterPad aeval_inputs[] = {
452  {
453  .name = "default",
454  .type = AVMEDIA_TYPE_AUDIO,
455  .filter_frame = filter_frame,
456  },
457 };
458 
459 static const AVFilterPad aeval_outputs[] = {
460  {
461  .name = "default",
462  .type = AVMEDIA_TYPE_AUDIO,
463  .config_props = aeval_config_output,
464  },
465 };
466 
467 const AVFilter ff_af_aeval = {
468  .name = "aeval",
469  .description = NULL_IF_CONFIG_SMALL("Filter audio signal according to a specified expression."),
470  .init = init,
471  .uninit = uninit,
472  .priv_size = sizeof(EvalContext),
473  FILTER_INPUTS(aeval_inputs),
474  FILTER_OUTPUTS(aeval_outputs),
476  .priv_class = &aeval_class,
478 };
479 
480 #endif /* CONFIG_AEVAL_FILTER */
EvalContext::expr
AVExpr ** expr
Definition: aeval.c:69
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:97
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:46
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:520
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
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:261
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:72
int64_t
long long int64_t
Definition: coverity.c:34
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
ff_set_common_samplerates_from_list
int ff_set_common_samplerates_from_list(AVFilterContext *ctx, const int *samplerates)
Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates))
Definition: formats.c:815
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:130
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:173
aeval_query_formats
static int aeval_query_formats(AVFilterContext *ctx)
Definition: aeval.c:349
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:456
ADD_EXPRESSION
#define ADD_EXPRESSION(expr_)
AVOption
AVOption.
Definition: opt.h:346
t0
#define t0
Definition: regdef.h:28
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
FLAGS
#define FLAGS
Definition: aeval.c:338
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:249
aeval_func1_names
static const char *const aeval_func1_names[]
Definition: aeval.c:85
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:821
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
config_props
static int config_props(AVFilterLink *outlink)
Definition: aeval.c:225
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
EvalContext::exprs
char * exprs
Definition: aeval.c:70
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: aeval.c:211
formats.h
VAR_T
@ VAR_T
Definition: aeval.c:54
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
EvalContext::same_chlayout
int same_chlayout
set output as input channel layout
Definition: aeval.c:67
val
static double val(void *priv, double ch)
Definition: aeval.c:78
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:359
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
EvalContext::var_values
double var_values[VAR_VARS_NB]
Definition: aeval.c:74
TS2T
#define TS2T(ts, tb)
Definition: internal.h:259
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
duration
int64_t duration
Definition: movenc.c:64
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:644
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:189
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
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:873
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:793
AVExpr
Definition: eval.c:159
ff_set_common_channel_layouts_from_list
int ff_set_common_channel_layouts_from_list(AVFilterContext *ctx, const AVChannelLayout *fmts)
Equivalent to ff_set_common_channel_layouts(ctx, ff_make_channel_layout_list(fmts))
Definition: formats.c:797
NAN
#define NAN
Definition: mathematics.h:115
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:90
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:679
aeval_config_output
static int aeval_config_output(AVFilterLink *outlink)
Definition: aeval.c:383
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_af_aeval
const AVFilter ff_af_aeval
parseutils.h
VAR_CH
@ VAR_CH
Definition: aeval.c:50
double
double
Definition: af_crystalizer.c:131
EvalContext
Definition: aeval.c:59
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_set_common_all_channel_counts
int ff_set_common_all_channel_counts(AVFilterContext *ctx)
Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())
Definition: formats.c:803
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:66
OFFSET
#define OFFSET(x)
Definition: aeval.c:337
eval.h
aeval_options
static const AVOption aeval_options[]
Definition: aeval.c:340
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:106
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:303
EvalContext::pts
int64_t pts
Definition: aeval.c:68
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: formats.c:966
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:543
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:65
VAR_VARS_NB
@ VAR_VARS_NB
Definition: aeval.c:56
aeval_func1
static double(*const aeval_func1[])(void *, double)
Definition: aeval.c:84
VAR_NB_IN_CHANNELS
@ VAR_NB_IN_CHANNELS
Definition: aeval.c:52
sample_rates
sample_rates
Definition: ffmpeg_filter.c:409
internal.h
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:147
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:830
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:424
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:255
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:405
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
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:166
EvalContext::sample_rate_str
char * sample_rate_str
Definition: aeval.c:61
ret
ret
Definition: filter_design.txt:187
EvalContext::chlayout_str
char * chlayout_str
Definition: aeval.c:64
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)
var_names
static const char *const var_names[]
Definition: aeval.c:39
channel_layout.h
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: aeval.c:412
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
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:432
VAR_NB_OUT_CHANNELS
@ VAR_NB_OUT_CHANNELS
Definition: aeval.c:53
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
activate
static int activate(AVFilterContext *ctx)
Definition: aeval.c:265
VAR_N
@ VAR_N
Definition: aeval.c:51
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
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:439
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
parse_channel_expressions
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
Definition: aeval.c:105
audio.h
EvalContext::n
uint64_t n
Definition: aeval.c:73
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:246
ff_parse_sample_rate
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
Definition: formats.c:954
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
Definition: opt.h:239
EvalContext::sample_rate
int sample_rate
Definition: aeval.c:62
ff_asrc_aevalsrc
const AVFilter ff_asrc_aevalsrc
VAR_S
@ VAR_S
Definition: aeval.c:55
EvalContext::channel_values
double * channel_values
Definition: aeval.c:75
EvalContext::chlayout
AVChannelLayout chlayout
Definition: aeval.c:63
EvalContext::nb_samples
int nb_samples
number of samples per requested frame
Definition: aeval.c:71