FFmpeg  4.4.5
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 "libavutil/avassert.h"
27 #include "libavutil/avstring.h"
29 #include "libavutil/eval.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/parseutils.h"
32 #include "avfilter.h"
33 #include "audio.h"
34 #include "internal.h"
35 
36 static const char * const var_names[] = {
37  "ch", ///< the value of the current channel
38  "n", ///< number of frame
39  "nb_in_channels",
40  "nb_out_channels",
41  "t", ///< timestamp expressed in seconds
42  "s", ///< sample rate
43  NULL
44 };
45 
46 enum var_name {
54 };
55 
56 typedef struct EvalContext {
57  const AVClass *class;
61  char *chlayout_str;
62  int nb_channels; ///< number of output channels
63  int nb_in_channels; ///< number of input channels
64  int same_chlayout; ///< set output as input channel layout
67  char *exprs;
68  int nb_samples; ///< number of samples per requested frame
70  uint64_t n;
72  double *channel_values;
74 } EvalContext;
75 
76 static double val(void *priv, double ch)
77 {
78  EvalContext *eval = priv;
79  return eval->channel_values[FFMIN((int)ch, eval->nb_in_channels-1)];
80 }
81 
82 static double (* const aeval_func1[])(void *, double) = { val, NULL };
83 static const char * const aeval_func1_names[] = { "val", NULL };
84 
85 #define OFFSET(x) offsetof(EvalContext, x)
86 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
87 
88 static const AVOption aevalsrc_options[]= {
89  { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS },
90  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
91  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
92  { "sample_rate", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
93  { "s", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
94  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
95  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
96  { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
97  { "c", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
98  { NULL }
99 };
100 
102 
104  int expected_nb_channels)
105 {
106  EvalContext *eval = ctx->priv;
107  char *args1 = av_strdup(eval->exprs);
108  char *expr, *last_expr = NULL, *buf;
109  double (* const *func1)(void *, double) = NULL;
110  const char * const *func1_names = NULL;
111  int i, ret = 0;
112 
113  if (!args1)
114  return AVERROR(ENOMEM);
115 
116  if (!eval->exprs) {
117  av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n");
118  return AVERROR(EINVAL);
119  }
120 
121  if (!strcmp(ctx->filter->name, "aeval")) {
122  func1 = aeval_func1;
124  }
125 
126 #define ADD_EXPRESSION(expr_) do { \
127  ret = av_dynarray_add_nofree(&eval->expr, \
128  &eval->nb_channels, NULL); \
129  if (ret < 0) \
130  goto end; \
131  eval->expr[eval->nb_channels-1] = NULL; \
132  ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
133  var_names, func1_names, func1, \
134  NULL, NULL, 0, ctx); \
135  if (ret < 0) \
136  goto end; \
137  } while (0)
138 
139  /* reset expressions */
140  for (i = 0; i < eval->nb_channels; i++) {
141  av_expr_free(eval->expr[i]);
142  eval->expr[i] = NULL;
143  }
144  av_freep(&eval->expr);
145  eval->nb_channels = 0;
146 
147  buf = args1;
148  while (expr = av_strtok(buf, "|", &buf)) {
149  ADD_EXPRESSION(expr);
150  last_expr = expr;
151  }
152 
153  if (expected_nb_channels > eval->nb_channels)
154  for (i = eval->nb_channels; i < expected_nb_channels; i++)
155  ADD_EXPRESSION(last_expr);
156 
157  if (expected_nb_channels > 0 && eval->nb_channels != expected_nb_channels) {
159  "Mismatch between the specified number of channel expressions '%d' "
160  "and the number of expected output channels '%d' for the specified channel layout\n",
161  eval->nb_channels, expected_nb_channels);
162  ret = AVERROR(EINVAL);
163  goto end;
164  }
165 
166 end:
167  av_free(args1);
168  return ret;
169 }
170 
172 {
173  EvalContext *eval = ctx->priv;
174  int ret = 0;
175 
176  if (eval->chlayout_str) {
177  if (!strcmp(eval->chlayout_str, "same") && !strcmp(ctx->filter->name, "aeval")) {
178  eval->same_chlayout = 1;
179  } else {
180  ret = ff_parse_channel_layout(&eval->chlayout, NULL, eval->chlayout_str, ctx);
181  if (ret < 0)
182  return ret;
183 
185  if (ret < 0)
186  return ret;
187  }
188  } else {
189  /* guess channel layout from nb expressions/channels */
190  if ((ret = parse_channel_expressions(ctx, -1)) < 0)
191  return ret;
192 
194  if (!eval->chlayout && eval->nb_channels <= 0) {
195  av_log(ctx, AV_LOG_ERROR, "Invalid number of channels '%d' provided\n",
196  eval->nb_channels);
197  return AVERROR(EINVAL);
198  }
199  }
200 
201  if (eval->sample_rate_str)
202  if ((ret = ff_parse_sample_rate(&eval->sample_rate, eval->sample_rate_str, ctx)))
203  return ret;
204  eval->n = 0;
205 
206  return ret;
207 }
208 
210 {
211  EvalContext *eval = ctx->priv;
212  int i;
213 
214  for (i = 0; i < eval->nb_channels; i++) {
215  av_expr_free(eval->expr[i]);
216  eval->expr[i] = NULL;
217  }
218  av_freep(&eval->expr);
219  av_freep(&eval->channel_values);
220 }
221 
222 static int config_props(AVFilterLink *outlink)
223 {
224  EvalContext *eval = outlink->src->priv;
225  char buf[128];
226 
227  outlink->time_base = (AVRational){1, eval->sample_rate};
228  outlink->sample_rate = eval->sample_rate;
229 
230  eval->var_values[VAR_S] = eval->sample_rate;
232  eval->var_values[VAR_NB_OUT_CHANNELS] = outlink->channels;
233 
234  av_get_channel_layout_string(buf, sizeof(buf), 0, eval->chlayout);
235 
236  av_log(outlink->src, AV_LOG_VERBOSE,
237  "sample_rate:%d chlayout:%s duration:%"PRId64"\n",
238  eval->sample_rate, buf, eval->duration);
239 
240  return 0;
241 }
242 
244 {
245  EvalContext *eval = ctx->priv;
247  int64_t chlayouts[] = { eval->chlayout ? eval->chlayout : FF_COUNT2LAYOUT(eval->nb_channels) , -1 };
248  int sample_rates[] = { eval->sample_rate, -1 };
251  int ret;
252 
254  if (!formats)
255  return AVERROR(ENOMEM);
257  if (ret < 0)
258  return ret;
259 
260  layouts = ff_make_format64_list(chlayouts);
261  if (!layouts)
262  return AVERROR(ENOMEM);
264  if (ret < 0)
265  return ret;
266 
268  if (!formats)
269  return AVERROR(ENOMEM);
271 }
272 
273 static int request_frame(AVFilterLink *outlink)
274 {
275  EvalContext *eval = outlink->src->priv;
276  AVFrame *samplesref;
277  int i, j;
278  int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate);
279  int nb_samples;
280 
281  if (eval->duration >= 0 && t >= eval->duration)
282  return AVERROR_EOF;
283 
284  if (eval->duration >= 0) {
285  nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
286  if (!nb_samples)
287  return AVERROR_EOF;
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  .request_frame = request_frame,
320  },
321  { NULL }
322 };
323 
325  .name = "aevalsrc",
326  .description = NULL_IF_CONFIG_SMALL("Generate an audio signal generated by an expression."),
327  .query_formats = query_formats,
328  .init = init,
329  .uninit = uninit,
330  .priv_size = sizeof(EvalContext),
331  .inputs = NULL,
332  .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 
349 
351 {
354  AVFilterLink *inlink = ctx->inputs[0];
355  AVFilterLink *outlink = ctx->outputs[0];
356  EvalContext *eval = ctx->priv;
357  static const enum AVSampleFormat sample_fmts[] = {
359  };
360  int ret;
361 
362  // inlink supports any channel layout
364  if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0)
365  return ret;
366 
367  if (eval->same_chlayout) {
369  if ((ret = ff_set_common_channel_layouts(ctx, layouts)) < 0)
370  return ret;
371  } else {
372  // outlink supports only requested output channel layout
373  layouts = NULL;
374  if ((ret = ff_add_channel_layout(&layouts,
375  eval->out_channel_layout ? eval->out_channel_layout :
376  FF_COUNT2LAYOUT(eval->nb_channels))) < 0)
377  return ret;
378  if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0)
379  return ret;
380  }
381 
383  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
384  return ret;
385 
388 }
389 
390 static int aeval_config_output(AVFilterLink *outlink)
391 {
392  AVFilterContext *ctx = outlink->src;
393  EvalContext *eval = ctx->priv;
394  AVFilterLink *inlink = ctx->inputs[0];
395  int ret;
396 
397  if (eval->same_chlayout) {
398  eval->chlayout = inlink->channel_layout;
399 
400  if ((ret = parse_channel_expressions(ctx, inlink->channels)) < 0)
401  return ret;
402  }
403 
404  eval->n = 0;
405  eval->nb_in_channels = eval->var_values[VAR_NB_IN_CHANNELS] = inlink->channels;
406  eval->var_values[VAR_NB_OUT_CHANNELS] = outlink->channels;
407  eval->var_values[VAR_S] = inlink->sample_rate;
408  eval->var_values[VAR_T] = NAN;
409 
411  inlink->channels, sizeof(*eval->channel_values));
412  if (!eval->channel_values)
413  return AVERROR(ENOMEM);
414 
415  return 0;
416 }
417 
418 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
419 {
420  EvalContext *eval = inlink->dst->priv;
421  AVFilterLink *outlink = inlink->dst->outputs[0];
422  int nb_samples = in->nb_samples;
423  AVFrame *out;
424  double t0;
425  int i, j;
426 
427  out = ff_get_audio_buffer(outlink, nb_samples);
428  if (!out) {
429  av_frame_free(&in);
430  return AVERROR(ENOMEM);
431  }
433 
434  t0 = TS2T(in->pts, inlink->time_base);
435 
436  /* evaluate expression for each single sample and for each channel */
437  for (i = 0; i < nb_samples; i++, eval->n++) {
438  eval->var_values[VAR_N] = eval->n;
439  eval->var_values[VAR_T] = t0 + i * (double)1/inlink->sample_rate;
440 
441  for (j = 0; j < inlink->channels; j++)
442  eval->channel_values[j] = *((double *) in->extended_data[j] + i);
443 
444  for (j = 0; j < outlink->channels; j++) {
445  eval->var_values[VAR_CH] = j;
446  *((double *) out->extended_data[j] + i) =
447  av_expr_eval(eval->expr[j], eval->var_values, eval);
448  }
449  }
450 
451  av_frame_free(&in);
452  return ff_filter_frame(outlink, out);
453 }
454 
455 #if CONFIG_AEVAL_FILTER
456 
457 static const AVFilterPad aeval_inputs[] = {
458  {
459  .name = "default",
460  .type = AVMEDIA_TYPE_AUDIO,
461  .filter_frame = filter_frame,
462  },
463  { NULL }
464 };
465 
466 static const AVFilterPad aeval_outputs[] = {
467  {
468  .name = "default",
469  .type = AVMEDIA_TYPE_AUDIO,
470  .config_props = aeval_config_output,
471  },
472  { NULL }
473 };
474 
476  .name = "aeval",
477  .description = NULL_IF_CONFIG_SMALL("Filter audio signal according to a specified expression."),
478  .query_formats = aeval_query_formats,
479  .init = init,
480  .uninit = uninit,
481  .priv_size = sizeof(EvalContext),
482  .inputs = aeval_inputs,
483  .outputs = aeval_outputs,
484  .priv_class = &aeval_class,
486 };
487 
488 #endif /* CONFIG_AEVAL_FILTER */
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
#define ADD_EXPRESSION(expr_)
@ VAR_NB_IN_CHANNELS
Definition: aeval.c:49
@ VAR_CH
Definition: aeval.c:47
@ VAR_N
Definition: aeval.c:48
@ VAR_VARS_NB
Definition: aeval.c:53
@ VAR_T
Definition: aeval.c:51
@ VAR_S
Definition: aeval.c:52
@ VAR_NB_OUT_CHANNELS
Definition: aeval.c:50
static double val(void *priv, double ch)
Definition: aeval.c:76
static int config_props(AVFilterLink *outlink)
Definition: aeval.c:222
static const AVOption aeval_options[]
Definition: aeval.c:341
static double(*const aeval_func1[])(void *, double)
Definition: aeval.c:82
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:243
static int aeval_query_formats(AVFilterContext *ctx)
Definition: aeval.c:350
AVFILTER_DEFINE_CLASS(aevalsrc)
#define FLAGS
Definition: aeval.c:339
static int request_frame(AVFilterLink *outlink)
Definition: aeval.c:273
static int parse_channel_expressions(AVFilterContext *ctx, int expected_nb_channels)
Definition: aeval.c:103
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: aeval.c:418
static const char *const var_names[]
Definition: aeval.c:36
static av_cold int init(AVFilterContext *ctx)
Definition: aeval.c:171
static const AVOption aevalsrc_options[]
Definition: aeval.c:88
static av_cold void uninit(AVFilterContext *ctx)
Definition: aeval.c:209
#define OFFSET(x)
Definition: aeval.c:338
static const char *const aeval_func1_names[]
Definition: aeval.c:83
static int aeval_config_output(AVFilterLink *outlink)
Definition: aeval.c:390
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
AVFilter ff_asrc_aevalsrc
AVFilter ff_af_aeval
#define av_cold
Definition: attributes.h:88
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:86
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
audio channel layout utility functions
#define FFMIN(a, b)
Definition: common.h:105
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
simple arithmetic expression evaluator
sample_rates
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:436
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:338
int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
Definition: formats.c:644
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
Definition: formats.c:632
AVFilterChannelLayouts * ff_make_format64_list(const int64_t *fmts)
Definition: formats.c:295
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:575
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:461
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates.
Definition: formats.c:568
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:421
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:103
@ AV_OPT_TYPE_DURATION
Definition: opt.h:239
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
#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:126
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
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
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:253
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:70
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:186
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
for(j=16;j >0;--j)
int i
Definition: input.c:407
#define TS2T(ts, tb)
Definition: internal.h:209
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
#define NAN
Definition: mathematics.h:64
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVOptions.
misc parsing utilities
#define t0
Definition: regdef.h:28
var_name
Definition: setts_bsf.c:50
formats
Definition: signature.h:48
Describe the class of an AVClass context structure.
Definition: log.h:67
Definition: eval.c:157
A list of supported channel layouts.
Definition: formats.h:86
An instance of a filter.
Definition: avfilter.h:341
void * priv
private data for use by the filter
Definition: avfilter.h:356
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:455
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
int sample_rate
Sample rate of the audio data.
Definition: frame.h:490
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:365
AVOption.
Definition: opt.h:248
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int64_t duration
Definition: aeval.c:69
int nb_channels
number of output channels
Definition: aeval.c:62
int same_chlayout
set output as input channel layout
Definition: aeval.c:64
char * chlayout_str
Definition: aeval.c:61
int nb_in_channels
number of input channels
Definition: aeval.c:63
int64_t chlayout
Definition: aeval.c:60
int nb_samples
number of samples per requested frame
Definition: aeval.c:68
double * channel_values
Definition: aeval.c:72
uint64_t n
Definition: aeval.c:70
AVExpr ** expr
Definition: aeval.c:66
int64_t out_channel_layout
Definition: aeval.c:73
char * exprs
Definition: aeval.c:67
int sample_rate
Definition: aeval.c:59
char * sample_rate_str
Definition: aeval.c:58
int64_t pts
Definition: aeval.c:65
double var_values[VAR_VARS_NB]
Definition: aeval.c:71
#define av_free(p)
#define av_realloc_f(p, o, n)
#define av_freep(p)
#define av_log(a,...)
FILE * out
Definition: movenc.c:54
int64_t duration
Definition: movenc.c:64
AVFormatContext * ctx
Definition: movenc.c:48
static double(*const func1[])(void *, double)
Definition: vf_rotate.c:190
static const char *const func1_names[]
Definition: vf_rotate.c:196