53 #define OFFSET(x) offsetof(AudioDelayContext, x)
54 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
95 #define DELAY(name, type, fill) \
96 static void delay_channel_## name ##p(ChanDelay *d, int nb_samples, \
97 const uint8_t *ssrc, uint8_t *ddst) \
99 const type *src = (type *)ssrc; \
100 type *dst = (type *)ddst; \
101 type *samples = (type *)d->samples; \
103 while (nb_samples) { \
104 if (d->delay_index < d->delay) { \
105 const int len = FFMIN(nb_samples, d->delay - d->delay_index); \
107 memcpy(&samples[d->delay_index], src, len * sizeof(type)); \
108 memset(dst, fill, len * sizeof(type)); \
109 d->delay_index += len; \
114 *dst = samples[d->index]; \
115 samples[d->index] = *src; \
119 d->index = d->index >= d->delay ? 0 : d->index; \
125 DELAY(s16, int16_t, 0)
128 DELAY(dbl,
double, 0)
134 char *p, *
arg, *saveptr =
NULL;
137 s->chandelay =
av_calloc(inlink->channels,
sizeof(*
s->chandelay));
140 s->nb_delays = inlink->channels;
144 for (
i = 0;
i <
s->nb_delays;
i++) {
156 if (ret != 2 ||
type !=
'S') {
157 div =
type ==
's' ? 1.0 : 1000.0;
162 d->
delay = delay * inlink->sample_rate / div;
172 for (
int j =
i; j <
s->nb_delays; j++)
173 s->chandelay[j].delay =
s->chandelay[
i-1].delay;
176 s->padding =
s->chandelay[0].delay;
177 for (
i = 1;
i <
s->nb_delays;
i++) {
184 for (
i = 0;
i <
s->nb_delays;
i++) {
191 for (
i = 0;
i <
s->nb_delays;
i++) {
204 switch (inlink->format) {
222 if (
ctx->is_disabled || !
s->delays)
232 for (
i = 0;
i <
s->nb_delays;
i++) {
243 out_frame->
pts =
s->next_pts;
261 int nb_samples =
FFMIN(
s->padding, 2048);
266 s->padding -= nb_samples;
292 if (
s->eof &&
s->max_delay) {
293 int nb_samples =
FFMIN(
s->max_delay, 2048);
298 s->max_delay -= nb_samples;
309 if (
s->eof &&
s->max_delay == 0) {
325 for (
int i = 0;
i <
s->nb_delays;
i++)
353 .priv_class = &adelay_class,
static enum AVSampleFormat sample_fmts[]
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
AVFILTER_DEFINE_CLASS(adelay)
#define DELAY(name, type, fill)
static const AVOption adelay_options[]
static const AVFilterPad adelay_inputs[]
static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static const AVFilterPad adelay_outputs[]
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
#define flags(name, subs,...)
simple arithmetic expression evaluator
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
@ AV_SAMPLE_FMT_DBLP
double, planar
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.
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 av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
#define AV_NOPTS_VALUE
Undefined timestamp value.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum MovChannelLayoutTag * layouts
typedef void(RENAME(mix_any_func_type))
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
int channels
Number of channels.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).
void(* delay_channel)(ChanDelay *d, int nb_samples, const uint8_t *src, uint8_t *dst)
#define av_malloc_array(a, b)