FFmpeg  4.3.9
af_aecho.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Paul B Mahol
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 #include "libavutil/avassert.h"
22 #include "libavutil/avstring.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/samplefmt.h"
25 #include "avfilter.h"
26 #include "audio.h"
27 #include "filters.h"
28 #include "internal.h"
29 
30 typedef struct AudioEchoContext {
31  const AVClass *class;
32  float in_gain, out_gain;
33  char *delays, *decays;
34  float *delay, *decay;
35  int nb_echoes;
39  int *samples;
40  int eof;
42 
44  uint8_t * const *src, uint8_t **dst,
45  int nb_samples, int channels);
47 
48 #define OFFSET(x) offsetof(AudioEchoContext, x)
49 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
50 
51 static const AVOption aecho_options[] = {
52  { "in_gain", "set signal input gain", OFFSET(in_gain), AV_OPT_TYPE_FLOAT, {.dbl=0.6}, 0, 1, A },
53  { "out_gain", "set signal output gain", OFFSET(out_gain), AV_OPT_TYPE_FLOAT, {.dbl=0.3}, 0, 1, A },
54  { "delays", "set list of signal delays", OFFSET(delays), AV_OPT_TYPE_STRING, {.str="1000"}, 0, 0, A },
55  { "decays", "set list of signal decays", OFFSET(decays), AV_OPT_TYPE_STRING, {.str="0.5"}, 0, 0, A },
56  { NULL }
57 };
58 
60 
61 static void count_items(char *item_str, int *nb_items)
62 {
63  char *p;
64 
65  *nb_items = 1;
66  for (p = item_str; *p; p++) {
67  if (*p == '|')
68  (*nb_items)++;
69  }
70 
71 }
72 
73 static void fill_items(char *item_str, int *nb_items, float *items)
74 {
75  char *p, *saveptr = NULL;
76  int i, new_nb_items = 0;
77 
78  p = item_str;
79  for (i = 0; i < *nb_items; i++) {
80  char *tstr = av_strtok(p, "|", &saveptr);
81  p = NULL;
82  if (tstr)
83  new_nb_items += av_sscanf(tstr, "%f", &items[new_nb_items]) == 1;
84  }
85 
86  *nb_items = new_nb_items;
87 }
88 
90 {
91  AudioEchoContext *s = ctx->priv;
92 
93  av_freep(&s->delay);
94  av_freep(&s->decay);
95  av_freep(&s->samples);
96 
97  if (s->delayptrs)
98  av_freep(&s->delayptrs[0]);
99  av_freep(&s->delayptrs);
100 }
101 
103 {
104  AudioEchoContext *s = ctx->priv;
105  int nb_delays, nb_decays, i;
106 
107  if (!s->delays || !s->decays) {
108  av_log(ctx, AV_LOG_ERROR, "Missing delays and/or decays.\n");
109  return AVERROR(EINVAL);
110  }
111 
112  count_items(s->delays, &nb_delays);
113  count_items(s->decays, &nb_decays);
114 
115  s->delay = av_realloc_f(s->delay, nb_delays, sizeof(*s->delay));
116  s->decay = av_realloc_f(s->decay, nb_decays, sizeof(*s->decay));
117  if (!s->delay || !s->decay)
118  return AVERROR(ENOMEM);
119 
120  fill_items(s->delays, &nb_delays, s->delay);
121  fill_items(s->decays, &nb_decays, s->decay);
122 
123  if (nb_delays != nb_decays) {
124  av_log(ctx, AV_LOG_ERROR, "Number of delays %d differs from number of decays %d.\n", nb_delays, nb_decays);
125  return AVERROR(EINVAL);
126  }
127 
128  s->nb_echoes = nb_delays;
129  if (!s->nb_echoes) {
130  av_log(ctx, AV_LOG_ERROR, "At least one decay & delay must be set.\n");
131  return AVERROR(EINVAL);
132  }
133 
134  s->samples = av_realloc_f(s->samples, nb_delays, sizeof(*s->samples));
135  if (!s->samples)
136  return AVERROR(ENOMEM);
137 
138  for (i = 0; i < nb_delays; i++) {
139  if (s->delay[i] <= 0 || s->delay[i] > 90000) {
140  av_log(ctx, AV_LOG_ERROR, "delay[%d]: %f is out of allowed range: (0, 90000]\n", i, s->delay[i]);
141  return AVERROR(EINVAL);
142  }
143  if (s->decay[i] <= 0 || s->decay[i] > 1) {
144  av_log(ctx, AV_LOG_ERROR, "decay[%d]: %f is out of allowed range: (0, 1]\n", i, s->decay[i]);
145  return AVERROR(EINVAL);
146  }
147  }
148 
150 
151  av_log(ctx, AV_LOG_DEBUG, "nb_echoes:%d\n", s->nb_echoes);
152  return 0;
153 }
154 
156 {
159  static const enum AVSampleFormat sample_fmts[] = {
163  };
164  int ret;
165 
166  layouts = ff_all_channel_counts();
167  if (!layouts)
168  return AVERROR(ENOMEM);
169  ret = ff_set_common_channel_layouts(ctx, layouts);
170  if (ret < 0)
171  return ret;
172 
173  formats = ff_make_format_list(sample_fmts);
174  if (!formats)
175  return AVERROR(ENOMEM);
176  ret = ff_set_common_formats(ctx, formats);
177  if (ret < 0)
178  return ret;
179 
180  formats = ff_all_samplerates();
181  if (!formats)
182  return AVERROR(ENOMEM);
183  return ff_set_common_samplerates(ctx, formats);
184 }
185 
186 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
187 
188 #define ECHO(name, type, min, max) \
189 static void echo_samples_## name ##p(AudioEchoContext *ctx, \
190  uint8_t **delayptrs, \
191  uint8_t * const *src, uint8_t **dst, \
192  int nb_samples, int channels) \
193 { \
194  const double out_gain = ctx->out_gain; \
195  const double in_gain = ctx->in_gain; \
196  const int nb_echoes = ctx->nb_echoes; \
197  const int max_samples = ctx->max_samples; \
198  int i, j, chan, av_uninit(index); \
199  \
200  av_assert1(channels > 0); /* would corrupt delay_index */ \
201  \
202  for (chan = 0; chan < channels; chan++) { \
203  const type *s = (type *)src[chan]; \
204  type *d = (type *)dst[chan]; \
205  type *dbuf = (type *)delayptrs[chan]; \
206  \
207  index = ctx->delay_index; \
208  for (i = 0; i < nb_samples; i++, s++, d++) { \
209  double out, in; \
210  \
211  in = *s; \
212  out = in * in_gain; \
213  for (j = 0; j < nb_echoes; j++) { \
214  int ix = index + max_samples - ctx->samples[j]; \
215  ix = MOD(ix, max_samples); \
216  out += dbuf[ix] * ctx->decay[j]; \
217  } \
218  out *= out_gain; \
219  \
220  *d = av_clipd(out, min, max); \
221  dbuf[index] = in; \
222  \
223  index = MOD(index + 1, max_samples); \
224  } \
225  } \
226  ctx->delay_index = index; \
227 }
228 
229 ECHO(dbl, double, -1.0, 1.0 )
230 ECHO(flt, float, -1.0, 1.0 )
231 ECHO(s16, int16_t, INT16_MIN, INT16_MAX)
232 ECHO(s32, int32_t, INT32_MIN, INT32_MAX)
233 
234 static int config_output(AVFilterLink *outlink)
235 {
236  AVFilterContext *ctx = outlink->src;
237  AudioEchoContext *s = ctx->priv;
238  float volume = 1.0;
239  int i;
240 
241  for (i = 0; i < s->nb_echoes; i++) {
242  s->samples[i] = s->delay[i] * outlink->sample_rate / 1000.0;
243  s->max_samples = FFMAX(s->max_samples, s->samples[i]);
244  volume += s->decay[i];
245  }
246 
247  if (s->max_samples <= 0) {
248  av_log(ctx, AV_LOG_ERROR, "Nothing to echo - missing delay samples.\n");
249  return AVERROR(EINVAL);
250  }
251  s->fade_out = s->max_samples;
252 
253  if (volume * s->in_gain * s->out_gain > 1.0)
254  av_log(ctx, AV_LOG_WARNING,
255  "out_gain %f can cause saturation of output\n", s->out_gain);
256 
257  switch (outlink->format) {
258  case AV_SAMPLE_FMT_DBLP: s->echo_samples = echo_samples_dblp; break;
259  case AV_SAMPLE_FMT_FLTP: s->echo_samples = echo_samples_fltp; break;
260  case AV_SAMPLE_FMT_S16P: s->echo_samples = echo_samples_s16p; break;
261  case AV_SAMPLE_FMT_S32P: s->echo_samples = echo_samples_s32p; break;
262  }
263 
264 
265  if (s->delayptrs)
266  av_freep(&s->delayptrs[0]);
267  av_freep(&s->delayptrs);
268 
270  outlink->channels,
271  s->max_samples,
272  outlink->format, 0);
273 }
274 
275 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
276 {
277  AVFilterContext *ctx = inlink->dst;
278  AudioEchoContext *s = ctx->priv;
279  AVFrame *out_frame;
280 
281  if (av_frame_is_writable(frame)) {
282  out_frame = frame;
283  } else {
284  out_frame = ff_get_audio_buffer(ctx->outputs[0], frame->nb_samples);
285  if (!out_frame) {
286  av_frame_free(&frame);
287  return AVERROR(ENOMEM);
288  }
289  av_frame_copy_props(out_frame, frame);
290  }
291 
292  s->echo_samples(s, s->delayptrs, frame->extended_data, out_frame->extended_data,
293  frame->nb_samples, inlink->channels);
294 
295  s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, (AVRational){1, inlink->sample_rate}, inlink->time_base);
296 
297  if (frame != out_frame)
298  av_frame_free(&frame);
299 
300  return ff_filter_frame(ctx->outputs[0], out_frame);
301 }
302 
303 static int request_frame(AVFilterLink *outlink)
304 {
305  AVFilterContext *ctx = outlink->src;
306  AudioEchoContext *s = ctx->priv;
307  int nb_samples = FFMIN(s->fade_out, 2048);
308  AVFrame *frame = ff_get_audio_buffer(outlink, nb_samples);
309 
310  if (!frame)
311  return AVERROR(ENOMEM);
312  s->fade_out -= nb_samples;
313 
315  frame->nb_samples,
316  outlink->channels,
317  frame->format);
318 
319  s->echo_samples(s, s->delayptrs, frame->extended_data, frame->extended_data,
320  frame->nb_samples, outlink->channels);
321 
322  frame->pts = s->next_pts;
323  if (s->next_pts != AV_NOPTS_VALUE)
324  s->next_pts += av_rescale_q(nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
325 
326  return ff_filter_frame(outlink, frame);
327 }
328 
330 {
331  AVFilterLink *inlink = ctx->inputs[0];
332  AVFilterLink *outlink = ctx->outputs[0];
333  AudioEchoContext *s = ctx->priv;
334  AVFrame *in;
335  int ret, status;
336  int64_t pts;
337 
338  FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
339 
340  ret = ff_inlink_consume_frame(inlink, &in);
341  if (ret < 0)
342  return ret;
343  if (ret > 0)
344  return filter_frame(inlink, in);
345 
346  if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
347  if (status == AVERROR_EOF)
348  s->eof = 1;
349  }
350 
351  if (s->eof && s->fade_out <= 0) {
353  return 0;
354  }
355 
356  if (!s->eof)
357  FF_FILTER_FORWARD_WANTED(outlink, inlink);
358 
359  return request_frame(outlink);
360 }
361 
362 static const AVFilterPad aecho_inputs[] = {
363  {
364  .name = "default",
365  .type = AVMEDIA_TYPE_AUDIO,
366  },
367  { NULL }
368 };
369 
370 static const AVFilterPad aecho_outputs[] = {
371  {
372  .name = "default",
373  .config_props = config_output,
374  .type = AVMEDIA_TYPE_AUDIO,
375  },
376  { NULL }
377 };
378 
380  .name = "aecho",
381  .description = NULL_IF_CONFIG_SMALL("Add echoing to the audio."),
382  .query_formats = query_formats,
383  .priv_size = sizeof(AudioEchoContext),
384  .priv_class = &aecho_class,
385  .init = init,
386  .activate = activate,
387  .uninit = uninit,
388  .inputs = aecho_inputs,
389  .outputs = aecho_outputs,
390 };
float, planar
Definition: samplefmt.h:69
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link&#39;s FIFO and update the link&#39;s stats.
Definition: avfilter.c:1476
#define NULL
Definition: coverity.c:32
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:586
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
#define av_realloc_f(p, o, n)
AVOption.
Definition: opt.h:246
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Main libavfilter public API header.
AVFILTER_DEFINE_CLASS(aecho)
static void count_items(char *item_str, int *nb_items)
Definition: af_aecho.c:61
double, planar
Definition: samplefmt.h:70
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: af_aecho.c:275
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
char * decays
Definition: af_aecho.c:33
int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Allocate a data pointers array, samples buffer for nb_samples samples, and fill data pointers and lin...
Definition: samplefmt.c:198
static void fill_items(char *item_str, int *nb_items, float *items)
Definition: af_aecho.c:73
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:300
const char * name
Pad name.
Definition: internal.h:60
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_aecho.c:89
float out_gain
Definition: af_aecho.c:32
void(* echo_samples)(struct AudioEchoContext *ctx, uint8_t **delayptrs, uint8_t *const *src, uint8_t **dst, int nb_samples, int channels)
Definition: af_aecho.c:43
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
static const AVOption aecho_options[]
Definition: af_aecho.c:51
uint8_t
#define av_cold
Definition: attributes.h:88
AVOptions.
#define OFFSET(x)
Definition: af_aecho.c:48
uint8_t ** delayptrs
Definition: af_aecho.c:37
#define ECHO(name, type, min, max)
Definition: af_aecho.c:188
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:393
static AVFrame * frame
static int request_frame(AVFilterLink *outlink)
Definition: af_aecho.c:303
#define AVERROR_EOF
End of file.
Definition: error.h:55
channels
Definition: aptx.h:33
#define av_log(a,...)
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
A filter pad used for either input or output.
Definition: internal.h:54
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
#define src
Definition: vp8dsp.c:254
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1431
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
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:605
static int query_formats(AVFilterContext *ctx)
Definition: af_aecho.c:155
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:237
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
#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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:188
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
static int config_output(AVFilterLink *outlink)
Definition: af_aecho.c:234
simple assert() macros that are a bit more flexible than ISO C assert().
#define FFMAX(a, b)
Definition: common.h:94
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Definition: avsscanf.c:962
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
Definition: filters.h:254
#define FFMIN(a, b)
Definition: common.h:96
signed 32 bits, planar
Definition: samplefmt.h:68
int32_t
AVFormatContext * ctx
Definition: movenc.c:48
#define s(width, name)
Definition: cbs_vp9.c:257
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
A list of supported channel layouts.
Definition: formats.h:85
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:373
AVFilter ff_af_aecho
Definition: af_aecho.c:379
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
typedef void(RENAME(mix_any_func_type))
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:595
long long int64_t
Definition: coverity.c:34
static const AVFilterPad aecho_outputs[]
Definition: af_aecho.c:370
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)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
Rational number (pair of numerator and denominator).
Definition: rational.h:58
const char * name
Filter name.
Definition: avfilter.h:148
int64_t next_pts
Definition: af_aecho.c:41
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
static av_cold int init(AVFilterContext *ctx)
Definition: af_aecho.c:102
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:439
static int activate(AVFilterContext *ctx)
Definition: af_aecho.c:329
static int64_t pts
char * delays
Definition: af_aecho.c:33
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:184
float * delay
Definition: af_aecho.c:34
#define A
Definition: af_aecho.c:49
static const AVFilterPad aecho_inputs[]
Definition: af_aecho.c:362
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:338
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:731
#define av_freep(p)
signed 16 bits, planar
Definition: samplefmt.h:67
formats
Definition: signature.h:48
internal API functions
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition...
Definition: formats.c:454
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:347
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:366
float * decay
Definition: af_aecho.c:34
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:593
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:659
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248