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|AV_OPT_FLAG_RUNTIME_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;
73 s->delay = (
s->distance_m * 100. +
s->distance_cm * 1. +
s->distance_mm * .1) *
77 while (new_size < min_size)
84 s->buf_size = new_size;
85 s->delay_frame->format =
inlink->format;
86 s->delay_frame->nb_samples = new_size;
87 #if FF_API_OLD_CHANNEL_LAYOUT
89 s->delay_frame->channel_layout =
inlink->channel_layout;
90 s->delay_frame->channels =
inlink->ch_layout.nb_channels;
104 const unsigned b_mask =
s->buf_size - 1;
105 const unsigned buf_size =
s->buf_size;
106 const unsigned delay =
s->delay;
107 const double dry =
s->dry;
108 const double wet =
s->wet;
109 unsigned r_ptr, w_ptr = 0;
120 for (ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
122 double *dst = (
double *)
out->extended_data[ch];
123 double *
buffer = (
double *)
s->delay_frame->extended_data[ch];
126 r_ptr = (w_ptr + buf_size - delay) & b_mask;
133 w_ptr = (w_ptr + 1) & b_mask;
134 r_ptr = (r_ptr + 1) & b_mask;
139 if (
ctx->is_disabled) {
149 char *res,
int res_len,
int flags)
159 s->delay = (
s->distance_m * 100. +
s->distance_cm * 1. +
s->distance_mm * .1) *
189 .
name =
"compensationdelay",
192 .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.
#define FF_ENABLE_DEPRECATION_WARNINGS
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#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 ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
int sample_rate
samples per second
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 FF_DISABLE_DEPRECATION_WARNINGS
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define FILTER_OUTPUTS(array)
#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,...)