FFmpeg
af_adelay.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/avstring.h"
22 #include "libavutil/mem.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 ChanDelay {
31  int64_t delay;
32  size_t delay_index;
33  size_t index;
34  unsigned int samples_size;
35  uint8_t *samples;
36 } ChanDelay;
37 
38 typedef struct AudioDelayContext {
39  const AVClass *class;
40  int all;
41  char *delays;
43  int nb_delays;
45  int64_t padding;
46  int64_t max_delay;
47  int64_t offset;
48  int64_t next_pts;
49  int eof;
50 
52 
53  void (*delay_channel)(ChanDelay *d, int nb_samples,
54  const uint8_t *src, uint8_t *dst);
55  int (*resize_channel_samples)(ChanDelay *d, int64_t new_delay);
57 
58 #define OFFSET(x) offsetof(AudioDelayContext, x)
59 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
60 
61 static const AVOption adelay_options[] = {
62  { "delays", "set list of delays for each channel", OFFSET(delays), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, A | AV_OPT_FLAG_RUNTIME_PARAM },
63  { "all", "use last available delay for remained channels", OFFSET(all), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A },
64  { NULL }
65 };
66 
67 AVFILTER_DEFINE_CLASS(adelay);
68 
69 #define DELAY(name, type, fill) \
70 static void delay_channel_## name ##p(ChanDelay *d, int nb_samples, \
71  const uint8_t *ssrc, uint8_t *ddst) \
72 { \
73  const type *src = (type *)ssrc; \
74  type *dst = (type *)ddst; \
75  type *samples = (type *)d->samples; \
76  \
77  while (nb_samples) { \
78  if (d->delay_index < d->delay) { \
79  const int len = FFMIN(nb_samples, d->delay - d->delay_index); \
80  \
81  memcpy(&samples[d->delay_index], src, len * sizeof(type)); \
82  memset(dst, fill, len * sizeof(type)); \
83  d->delay_index += len; \
84  src += len; \
85  dst += len; \
86  nb_samples -= len; \
87  } else { \
88  *dst = samples[d->index]; \
89  samples[d->index] = *src; \
90  nb_samples--; \
91  d->index++; \
92  src++, dst++; \
93  d->index = d->index >= d->delay ? 0 : d->index; \
94  } \
95  } \
96 }
97 
98 DELAY(u8, uint8_t, 0x80)
99 DELAY(s16, int16_t, 0)
100 DELAY(s32, int32_t, 0)
101 DELAY(flt, float, 0)
102 DELAY(dbl, double, 0)
103 
104 #define CHANGE_DELAY(name, type, fill) \
105 static int resize_samples_## name ##p(ChanDelay *d, int64_t new_delay) \
106 { \
107  type *samples; \
108  \
109  if (new_delay == d->delay) { \
110  return 0; \
111  } \
112  \
113  if (new_delay == 0) { \
114  av_freep(&d->samples); \
115  d->samples_size = 0; \
116  d->delay = 0; \
117  d->index = 0; \
118  d->delay_index = 0; \
119  return 0; \
120  } \
121  \
122  samples = (type *) av_fast_realloc(d->samples, &d->samples_size, new_delay * sizeof(type)); \
123  if (!samples) { \
124  return AVERROR(ENOMEM); \
125  } \
126  \
127  if (new_delay < d->delay) { \
128  if (d->index > new_delay) { \
129  d->index -= new_delay; \
130  memmove(samples, &samples[new_delay], d->index * sizeof(type)); \
131  d->delay_index = new_delay; \
132  } else if (d->delay_index > d->index) { \
133  memmove(&samples[d->index], &samples[d->index+(d->delay-new_delay)], \
134  (new_delay - d->index) * sizeof(type)); \
135  d->delay_index -= d->delay - new_delay; \
136  } \
137  } else { \
138  size_t block_size; \
139  if (d->delay_index >= d->delay) { \
140  block_size = (d->delay - d->index) * sizeof(type); \
141  memmove(&samples[d->index+(new_delay - d->delay)], &samples[d->index], block_size); \
142  d->delay_index = new_delay; \
143  } else { \
144  d->delay_index += new_delay - d->delay; \
145  } \
146  block_size = (new_delay - d->delay) * sizeof(type); \
147  memset(&samples[d->index], fill, block_size); \
148  } \
149  d->delay = new_delay; \
150  d->samples = (void *) samples; \
151  return 0; \
152 }
153 
154 CHANGE_DELAY(u8, uint8_t, 0x80)
155 CHANGE_DELAY(s16, int16_t, 0)
156 CHANGE_DELAY(s32, int32_t, 0)
157 CHANGE_DELAY(flt, float, 0)
158 CHANGE_DELAY(dbl, double, 0)
159 
160 static int parse_delays(char *p, char **saveptr, int64_t *result, AVFilterContext *ctx, int sample_rate) {
161  float delay, div;
162  int ret;
163  char *arg;
164  char type = 0;
165 
166  if (!(arg = av_strtok(p, "|", saveptr)))
167  return 1;
168 
169  ret = av_sscanf(arg, "%"SCNd64"%c", result, &type);
170  if (ret != 2 || type != 'S') {
171  div = type == 's' ? 1.0 : 1000.0;
172  if (av_sscanf(arg, "%f", &delay) != 1) {
173  av_log(ctx, AV_LOG_ERROR, "Invalid syntax for delay.\n");
174  return AVERROR(EINVAL);
175  }
176  *result = delay * sample_rate / div;
177  }
178 
179  if (*result < 0) {
180  av_log(ctx, AV_LOG_ERROR, "Delay must be non negative number.\n");
181  return AVERROR(EINVAL);
182  }
183  return 0;
184 }
185 
187 {
188  AVFilterContext *ctx = inlink->dst;
189  AudioDelayContext *s = ctx->priv;
190  char *p, *saveptr = NULL;
191  int i;
192 
193  s->next_pts = AV_NOPTS_VALUE;
194  s->chandelay = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->chandelay));
195  if (!s->chandelay)
196  return AVERROR(ENOMEM);
197  s->nb_delays = inlink->ch_layout.nb_channels;
198  s->block_align = av_get_bytes_per_sample(inlink->format);
199 
200  p = s->delays;
201  for (i = 0; i < s->nb_delays; i++) {
202  ChanDelay *d = &s->chandelay[i];
203  int ret;
204 
205  ret = parse_delays(p, &saveptr, &d->delay, ctx, inlink->sample_rate);
206  if (ret == 1)
207  break;
208  else if (ret < 0)
209  return ret;
210  p = NULL;
211  }
212 
213  if (s->all && i) {
214  for (int j = i; j < s->nb_delays; j++)
215  s->chandelay[j].delay = s->chandelay[i-1].delay;
216  }
217 
218  s->padding = s->chandelay[0].delay;
219  for (i = 1; i < s->nb_delays; i++) {
220  ChanDelay *d = &s->chandelay[i];
221 
222  s->padding = FFMIN(s->padding, d->delay);
223  }
224 
225  if (s->padding) {
226  for (i = 0; i < s->nb_delays; i++) {
227  ChanDelay *d = &s->chandelay[i];
228 
229  d->delay -= s->padding;
230  }
231 
232  s->offset = av_rescale_q(s->padding,
233  av_make_q(1, inlink->sample_rate),
234  inlink->time_base);
235  }
236 
237  for (i = 0; i < s->nb_delays; i++) {
238  ChanDelay *d = &s->chandelay[i];
239 
240  if (!d->delay)
241  continue;
242 
243  if (d->delay > SIZE_MAX) {
244  av_log(ctx, AV_LOG_ERROR, "Requested delay is too big.\n");
245  return AVERROR(EINVAL);
246  }
247 
248  d->samples = av_malloc_array(d->delay, s->block_align);
249  if (!d->samples)
250  return AVERROR(ENOMEM);
251  d->samples_size = d->delay * s->block_align;
252 
253  s->max_delay = FFMAX(s->max_delay, d->delay);
254  }
255 
256  switch (inlink->format) {
257  case AV_SAMPLE_FMT_U8P : s->delay_channel = delay_channel_u8p ;
258  s->resize_channel_samples = resize_samples_u8p; break;
259  case AV_SAMPLE_FMT_S16P: s->delay_channel = delay_channel_s16p;
260  s->resize_channel_samples = resize_samples_s16p; break;
261  case AV_SAMPLE_FMT_S32P: s->delay_channel = delay_channel_s32p;
262  s->resize_channel_samples = resize_samples_s32p; break;
263  case AV_SAMPLE_FMT_FLTP: s->delay_channel = delay_channel_fltp;
264  s->resize_channel_samples = resize_samples_fltp; break;
265  case AV_SAMPLE_FMT_DBLP: s->delay_channel = delay_channel_dblp;
266  s->resize_channel_samples = resize_samples_dblp; break;
267  }
268 
269  return 0;
270 }
271 
272 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
273  char *res, int res_len, int flags)
274 {
275  int ret = AVERROR(ENOSYS);
276  AVFilterLink *inlink = ctx->inputs[0];
277  AudioDelayContext *s = ctx->priv;
278 
279  if (!strcmp(cmd, "delays")) {
280  int64_t delay;
281  char *p, *saveptr = NULL;
282  int64_t all_delay = -1;
283  int64_t max_delay = 0;
284  char *args_cpy = av_strdup(args);
285  if (args_cpy == NULL) {
286  return AVERROR(ENOMEM);
287  }
288 
289  ret = 0;
290  p = args_cpy;
291 
292  if (!strncmp(args, "all:", 4)) {
293  p = &args_cpy[4];
294  ret = parse_delays(p, &saveptr, &all_delay, ctx, inlink->sample_rate);
295  if (ret == 1)
296  ret = AVERROR(EINVAL);
297  else if (ret == 0)
298  delay = all_delay;
299  }
300 
301  if (!ret) {
302  for (int i = 0; i < s->nb_delays; i++) {
303  ChanDelay *d = &s->chandelay[i];
304 
305  if (all_delay < 0) {
306  ret = parse_delays(p, &saveptr, &delay, ctx, inlink->sample_rate);
307  if (ret != 0) {
308  ret = 0;
309  break;
310  }
311  p = NULL;
312  }
313 
314  ret = s->resize_channel_samples(d, delay);
315  if (ret)
316  break;
317  max_delay = FFMAX(max_delay, d->delay);
318  }
319  s->max_delay = FFMAX(s->max_delay, max_delay);
320  }
321  av_freep(&args_cpy);
322  }
323  return ret;
324 }
325 
327 {
328  AVFilterContext *ctx = inlink->dst;
329  AVFilterLink *outlink = ctx->outputs[0];
330  AudioDelayContext *s = ctx->priv;
331  AVFrame *out_frame;
332  int i;
333 
334  if (ctx->is_disabled || !s->delays) {
335  s->input = NULL;
336  return ff_filter_frame(outlink, frame);
337  }
338 
339  s->next_pts = av_rescale_q(frame->pts, inlink->time_base, outlink->time_base);
340 
341  out_frame = ff_get_audio_buffer(outlink, frame->nb_samples);
342  if (!out_frame) {
343  s->input = NULL;
345  return AVERROR(ENOMEM);
346  }
347  av_frame_copy_props(out_frame, frame);
348 
349  for (i = 0; i < s->nb_delays; i++) {
350  ChanDelay *d = &s->chandelay[i];
351  const uint8_t *src = frame->extended_data[i];
352  uint8_t *dst = out_frame->extended_data[i];
353 
354  if (!d->delay)
355  memcpy(dst, src, frame->nb_samples * s->block_align);
356  else
357  s->delay_channel(d, frame->nb_samples, src, dst);
358  }
359 
360  out_frame->pts = s->next_pts + s->offset;
361  out_frame->duration = av_rescale_q(out_frame->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
362  s->next_pts += out_frame->duration;
364  s->input = NULL;
365  return ff_filter_frame(outlink, out_frame);
366 }
367 
369 {
370  AVFilterLink *inlink = ctx->inputs[0];
371  AVFilterLink *outlink = ctx->outputs[0];
372  AudioDelayContext *s = ctx->priv;
373  AVFrame *frame = NULL;
374  int ret, status;
375  int64_t pts;
376 
378 
379  if (!s->input) {
380  ret = ff_inlink_consume_frame(inlink, &s->input);
381  if (ret < 0)
382  return ret;
383  }
384 
386  if (status == AVERROR_EOF)
387  s->eof = 1;
388  }
389 
390  if (s->next_pts == AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE)
391  s->next_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
392 
393  if (s->padding) {
394  int nb_samples = FFMIN(s->padding, 2048);
395 
396  frame = ff_get_audio_buffer(outlink, nb_samples);
397  if (!frame)
398  return AVERROR(ENOMEM);
399  s->padding -= nb_samples;
400 
401  av_samples_set_silence(frame->extended_data, 0,
402  frame->nb_samples,
403  outlink->ch_layout.nb_channels,
404  frame->format);
405 
406  frame->duration = av_rescale_q(frame->nb_samples,
407  (AVRational){1, outlink->sample_rate},
408  outlink->time_base);
409  frame->pts = s->next_pts;
410  s->next_pts += frame->duration;
411 
412  return ff_filter_frame(outlink, frame);
413  }
414 
415  if (s->input)
416  return filter_frame(inlink, s->input);
417 
418  if (s->eof && s->max_delay) {
419  int nb_samples = FFMIN(s->max_delay, 2048);
420 
421  frame = ff_get_audio_buffer(outlink, nb_samples);
422  if (!frame)
423  return AVERROR(ENOMEM);
424  s->max_delay -= nb_samples;
425 
426  av_samples_set_silence(frame->extended_data, 0,
427  frame->nb_samples,
428  outlink->ch_layout.nb_channels,
429  frame->format);
430 
431  frame->duration = av_rescale_q(frame->nb_samples,
432  (AVRational){1, outlink->sample_rate},
433  outlink->time_base);
434  frame->pts = s->next_pts;
435  s->next_pts += frame->duration;
436  return filter_frame(inlink, frame);
437  }
438 
439  if (s->eof && s->max_delay == 0) {
440  ff_outlink_set_status(outlink, AVERROR_EOF, s->next_pts);
441  return 0;
442  }
443 
444  if (!s->eof)
446 
447  return FFERROR_NOT_READY;
448 }
449 
451 {
452  AudioDelayContext *s = ctx->priv;
453 
454  if (s->chandelay) {
455  for (int i = 0; i < s->nb_delays; i++)
456  av_freep(&s->chandelay[i].samples);
457  }
458  av_freep(&s->chandelay);
459 }
460 
461 static const AVFilterPad adelay_inputs[] = {
462  {
463  .name = "default",
464  .type = AVMEDIA_TYPE_AUDIO,
465  .config_props = config_input,
466  },
467 };
468 
470  .name = "adelay",
471  .description = NULL_IF_CONFIG_SMALL("Delay one or more audio channels."),
472  .priv_size = sizeof(AudioDelayContext),
473  .priv_class = &adelay_class,
474  .activate = activate,
475  .uninit = uninit,
481  .process_command = process_command,
482 };
AudioDelayContext::next_pts
int64_t next_pts
Definition: af_adelay.c:48
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
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AudioDelayContext::resize_channel_samples
int(* resize_channel_samples)(ChanDelay *d, int64_t new_delay)
Definition: af_adelay.c:55
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
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
AVFrame::duration
int64_t duration
Duration of the frame, in the same units as pts.
Definition: frame.h:780
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
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:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:486
av_samples_set_silence
int av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:246
AVOption
AVOption.
Definition: opt.h:346
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(adelay)
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
ChanDelay
Definition: af_adelay.c:30
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
ChanDelay::delay
int64_t delay
Definition: af_adelay.c:31
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
ff_af_adelay
const AVFilter ff_af_adelay
Definition: af_adelay.c:469
sample_rate
sample_rate
Definition: ffmpeg_filter.c:424
OFFSET
#define OFFSET(x)
Definition: af_adelay.c:58
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1442
AudioDelayContext
Definition: af_adelay.c:38
samplefmt.h
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:644
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
activate
static int activate(AVFilterContext *ctx)
Definition: af_adelay.c:368
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_adelay.c:186
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AudioDelayContext::delay_channel
void(* delay_channel)(ChanDelay *d, int nb_samples, const uint8_t *src, uint8_t *dst)
Definition: af_adelay.c:53
av_cold
#define av_cold
Definition: attributes.h:90
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
s
#define s(width, name)
Definition: cbs_vp9.c:198
AudioDelayContext::delays
char * delays
Definition: af_adelay.c:41
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
adelay_options
static const AVOption adelay_options[]
Definition: af_adelay.c:61
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AudioDelayContext::nb_delays
int nb_delays
Definition: af_adelay.c:43
AudioDelayContext::padding
int64_t padding
Definition: af_adelay.c:45
av_rescale_q
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
arg
const char * arg
Definition: jacosubdec.c:67
av_sscanf
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Definition: avsscanf.c:962
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
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:709
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
parse_delays
static int parse_delays(char *p, char **saveptr, int64_t *result, AVFilterContext *ctx, int sample_rate)
Definition: af_adelay.c:160
A
#define A
Definition: af_adelay.c:59
ff_audio_default_filterpad
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition: audio.c:33
ff_inlink_acknowledge_status
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:1389
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
AV_SAMPLE_FMT_U8P
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
Definition: samplefmt.h:63
DELAY
#define DELAY(name, type, fill)
Definition: af_adelay.c:69
AudioDelayContext::block_align
int block_align
Definition: af_adelay.c:44
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: af_adelay.c:326
AudioDelayContext::input
AVFrame * input
Definition: af_adelay.c:51
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
internal.h
ChanDelay::index
size_t index
Definition: af_adelay.c:33
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:454
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:108
AudioDelayContext::chandelay
ChanDelay * chandelay
Definition: af_adelay.c:42
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:435
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
ChanDelay::samples
uint8_t * samples
Definition: af_adelay.c:35
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
CHANGE_DELAY
#define CHANGE_DELAY(name, type, fill)
Definition: af_adelay.c:104
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
frame
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
status
ov_status_e status
Definition: dnn_backend_openvino.c:121
adelay_inputs
static const AVFilterPad adelay_inputs[]
Definition: af_adelay.c:461
AV_OPT_FLAG_RUNTIME_PARAM
#define AV_OPT_FLAG_RUNTIME_PARAM
A generic parameter which can be set by the user at runtime.
Definition: opt.h:294
avfilter.h
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_adelay.c:272
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
AudioDelayContext::eof
int eof
Definition: af_adelay.c:49
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:272
mem.h
audio.h
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AudioDelayContext::all
int all
Definition: af_adelay.c:40
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
d
d
Definition: ffmpeg_filter.c:424
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_adelay.c:450
int32_t
int32_t
Definition: audioconvert.c:56
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:155
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ChanDelay::delay_index
size_t delay_index
Definition: af_adelay.c:32
ChanDelay::samples_size
unsigned int samples_size
Definition: af_adelay.c:34
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
AudioDelayContext::max_delay
int64_t max_delay
Definition: af_adelay.c:46
int
int
Definition: ffmpeg_filter.c:424
AudioDelayContext::offset
int64_t offset
Definition: af_adelay.c:47
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: internal.h:170