22 #include "libavutil/avstring.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/samplefmt.h"
49 #define OFFSET(x) offsetof(AudioDelayContext, x)
50 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
87 #define DELAY(name, type, fill) \
88 static void delay_channel_## name ##p(ChanDelay *d, int nb_samples, \
89 const uint8_t *ssrc, uint8_t *ddst) \
91 const type *src = (type *)ssrc; \
92 type *dst = (type *)ddst; \
93 type *samples = (type *)d->samples; \
95 while (nb_samples) { \
96 if (d->delay_index < d->delay) { \
97 const int len = FFMIN(nb_samples, d->delay - d->delay_index); \
99 memcpy(&samples[d->delay_index], src, len * sizeof(type)); \
100 memset(dst, fill, len * sizeof(type)); \
101 d->delay_index += len; \
106 *dst = samples[d->index]; \
107 samples[d->index] = *src; \
111 d->index = d->index >= d->delay ? 0 : d->index; \
117 DELAY(s16, int16_t, 0)
120 DELAY(dbl,
double, 0)
126 char *p, *
arg, *saveptr = NULL;
140 if (!(arg =
av_strtok(p,
"|", &saveptr)))
144 sscanf(arg,
"%f", &delay);
146 d->
delay = delay * inlink->sample_rate / 1000.0;
171 switch (inlink->format) {
278 .priv_class = &adelay_class,
AVFilter avfilter_af_adelay
void * av_calloc(size_t nmemb, size_t size) av_malloc_attrib
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
This structure describes decoded (raw) audio or video data.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
uint8_t ** extended_data
pointers to the data planes/channels.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static enum AVSampleFormat formats[]
int is_disabled
the enabled state from the last expression evaluation
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
void(* delay_channel)(ChanDelay *d, int nb_samples, const uint8_t *src, uint8_t *dst)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static const AVOption adelay_options[]
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
static av_cold void uninit(AVFilterContext *ctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int query_formats(AVFilterContext *ctx)
A list of supported channel layouts.
Main libavfilter public API header.
AVFilterLink ** outputs
array of pointers to output links
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
AVSampleFormat
Audio Sample Formats.
typedef void(RENAME(mix_any_func_type))
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
rational number numerator/denominator
AVFilterContext * dst
dest filter
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
enum MovChannelLayoutTag * layouts
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.
static void * av_malloc_array(size_t nmemb, size_t size)
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()...
int channels
Number of channels.
static const AVFilterPad adelay_inputs[]
static int config_input(AVFilterLink *inlink)
#define AVFILTER_DEFINE_CLASS(fname)
static const AVFilterPad adelay_outputs[]
static enum AVSampleFormat sample_fmts[]
static int request_frame(AVFilterLink *outlink)
#define DELAY(name, type, fill)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_NOPTS_VALUE
Undefined timestamp value.