FFmpeg
Data Structures | Macros | Functions | Variables
af_adelay.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "avfilter.h"
#include "audio.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  ChanDelay
 
struct  AudioDelayContext
 

Macros

#define OFFSET(x)   offsetof(AudioDelayContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define DELAY(name, type, fill)
 
#define CHANGE_DELAY(name, type, fill)
 

Functions

 AVFILTER_DEFINE_CLASS (adelay)
 
static int parse_delays (char *p, char **saveptr, int64_t *result, AVFilterContext *ctx, int sample_rate)
 
static int config_input (AVFilterLink *inlink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption adelay_options []
 
static const AVFilterPad adelay_inputs []
 
const AVFilter ff_af_adelay
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(AudioDelayContext, x)

Definition at line 57 of file af_adelay.c.

◆ A

Definition at line 58 of file af_adelay.c.

◆ DELAY

#define DELAY (   name,
  type,
  fill 
)
Value:
static void delay_channel_## name ##p(ChanDelay *d, int nb_samples, \
const uint8_t *ssrc, uint8_t *ddst) \
{ \
const type *src = (type *)ssrc; \
type *dst = (type *)ddst; \
type *samples = (type *)d->samples; \
\
while (nb_samples) { \
if (d->delay_index < d->delay) { \
const int len = FFMIN(nb_samples, d->delay - d->delay_index); \
\
memcpy(&samples[d->delay_index], src, len * sizeof(type)); \
memset(dst, fill, len * sizeof(type)); \
d->delay_index += len; \
src += len; \
dst += len; \
nb_samples -= len; \
} else { \
*dst = samples[d->index]; \
samples[d->index] = *src; \
nb_samples--; \
d->index++; \
src++, dst++; \
d->index = d->index >= d->delay ? 0 : d->index; \
} \
} \
}

Definition at line 68 of file af_adelay.c.

◆ CHANGE_DELAY

#define CHANGE_DELAY (   name,
  type,
  fill 
)

Definition at line 103 of file af_adelay.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( adelay  )

◆ parse_delays()

static int parse_delays ( char *  p,
char **  saveptr,
int64_t result,
AVFilterContext ctx,
int  sample_rate 
)
static

Definition at line 159 of file af_adelay.c.

Referenced by config_input(), and process_command().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 185 of file af_adelay.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 271 of file af_adelay.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 325 of file af_adelay.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 367 of file af_adelay.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 449 of file af_adelay.c.

Variable Documentation

◆ adelay_options

const AVOption adelay_options[]
static
Initial value:
= {
{ "delays", "set list of delays for each channel", OFFSET(delays), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, A | AV_OPT_FLAG_RUNTIME_PARAM },
{ "all", "use last available delay for remained channels", OFFSET(all), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A },
{ NULL }
}

Definition at line 60 of file af_adelay.c.

◆ adelay_inputs

const AVFilterPad adelay_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}

Definition at line 460 of file af_adelay.c.

◆ ff_af_adelay

const AVFilter ff_af_adelay
Initial value:
= {
.name = "adelay",
.description = NULL_IF_CONFIG_SMALL("Delay one or more audio channels."),
.priv_size = sizeof(AudioDelayContext),
.priv_class = &adelay_class,
.process_command = process_command,
}

Definition at line 468 of file af_adelay.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
name
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 default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
ChanDelay
Definition: af_adelay.c:29
OFFSET
#define OFFSET(x)
Definition: af_adelay.c:57
AudioDelayContext
Definition: af_adelay.c:37
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
activate
static int activate(AVFilterContext *ctx)
Definition: af_adelay.c:367
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_adelay.c:185
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: filters.h:250
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
A
#define A
Definition: af_adelay.c:58
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:34
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
len
int len
Definition: vorbis_enc_data.h:426
adelay_inputs
static const AVFilterPad adelay_inputs[]
Definition: af_adelay.c:460
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:377
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:271
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_adelay.c:449
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:190
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
src
#define src
Definition: vp8dsp.c:248