Go to the documentation of this file.
42 #define OFFSET(x) offsetof(CompensationDelayContext, x)
43 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
58 #define COMP_DELAY_MAX_DISTANCE (100.0 * 100.0 + 100.0 * 1.0 + 1.0)
60 #define COMP_DELAY_SOUND_SPEED_KM_H(temp) 1.85325 * (643.95 * sqrt(((temp + 273.15) / 273.15)))
61 #define COMP_DELAY_SOUND_SPEED_CM_S(temp) (COMP_DELAY_SOUND_SPEED_KM_H(temp) * (1000.0 * 100.0) / (60.0 * 60.0) )
62 #define COMP_DELAY_SOUND_FRONT_DELAY(temp) (1.0 / COMP_DELAY_SOUND_SPEED_CM_S(temp))
64 #define COMP_DELAY_MAX_DELAY (COMP_DELAY_MAX_DISTANCE * COMP_DELAY_SOUND_FRONT_DELAY(50))
70 unsigned min_size, new_size = 1;
72 s->delay = (
s->distance_m * 100. +
s->distance_cm * 1. +
s->distance_mm * .1) *
76 while (new_size < min_size)
83 s->buf_size = new_size;
84 s->delay_frame->format =
inlink->format;
85 s->delay_frame->nb_samples = new_size;
86 s->delay_frame->channel_layout =
inlink->channel_layout;
95 const unsigned b_mask =
s->buf_size - 1;
96 const unsigned buf_size =
s->buf_size;
97 const unsigned delay =
s->delay;
98 const double dry =
s->dry;
99 const double wet =
s->wet;
100 unsigned r_ptr, w_ptr = 0;
111 for (ch = 0; ch <
inlink->channels; ch++) {
113 double *dst = (
double *)
out->extended_data[ch];
114 double *
buffer = (
double *)
s->delay_frame->extended_data[ch];
117 r_ptr = (w_ptr + buf_size - delay) & b_mask;
124 w_ptr = (w_ptr + 1) & b_mask;
125 r_ptr = (r_ptr + 1) & b_mask;
158 .
name =
"compensationdelay",
161 .priv_class = &compensationdelay_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static int config_input(AVFilterLink *inlink)
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 av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVFilter ff_af_compensationdelay
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
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.
static const AVFilterPad compensationdelay_inputs[]
static const AVOption compensationdelay_options[]
const char * name
Filter name.
A link between two filters.
#define COMP_DELAY_MAX_DELAY
AVFILTER_DEFINE_CLASS(compensationdelay)
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define FILTER_INPUTS(array)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVFilterPad compensationdelay_outputs[]
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t ** extended_data
pointers to the data planes/channels.
#define COMP_DELAY_SOUND_FRONT_DELAY(temp)
const char * name
Pad name.
static av_cold void uninit(AVFilterContext *ctx)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
@ AV_SAMPLE_FMT_DBLP
double, planar
#define FILTER_OUTPUTS(array)