Go to the documentation of this file.
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;
140 s->nb_delays =
inlink->channels;
144 for (
i = 0;
i <
s->nb_delays;
i++) {
157 div =
type ==
's' ? 1.0 : 1000.0;
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++) {
222 if (
ctx->is_disabled || !
s->delays)
232 for (
i = 0;
i <
s->nb_delays;
i++) {
238 memcpy(dst,
src,
frame->nb_samples *
s->block_align);
240 s->delay_channel(d,
frame->nb_samples,
src, dst);
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,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
A list of supported channel layouts.
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
#define AVERROR_EOF
End of file.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVFILTER_DEFINE_CLASS(adelay)
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
int channels
Number of channels.
static int query_formats(AVFilterContext *ctx)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
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
A filter pad used for either input or output.
static int activate(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* delay_channel)(ChanDelay *d, int nb_samples, const uint8_t *src, uint8_t *dst)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
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().
static const AVFilterPad outputs[]
static const AVOption adelay_options[]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static const AVFilterPad adelay_outputs[]
Rational number (pair of numerator and denominator).
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 inputs
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
#define DELAY(name, type, fill)
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
FF_FILTER_FORWARD_WANTED(outlink, inlink)
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
int sample_rate
samples per second
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
uint8_t ** extended_data
pointers to the data planes/channels.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
const char * name
Pad name.
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.
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
static const AVFilterPad adelay_inputs[]
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
@ AV_SAMPLE_FMT_DBLP
double, planar
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static av_cold void uninit(AVFilterContext *ctx)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)