Go to the documentation of this file.
72 double w0 = 2 *
M_PI * (1. -
s->range) * 2100 /
inlink->sample_rate;
75 alpha = sin(w0) / 2 * sqrt((
A + 1 /
A) * (1 /
s->slope - 1) + 2);
77 s->a0 = (
A + 1) + (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha;
78 s->a1 = -2 * ((
A - 1) + (
A + 1) * cos(w0));
79 s->a2 = (
A + 1) + (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha;
80 s->b0 =
A * ((
A + 1) - (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha);
81 s->b1 = 2 *
A * ((
A - 1) - (
A + 1) * cos(w0));
82 s->b2 =
A * ((
A + 1) - (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha);
90 if (
s->block_samples == 0 &&
s->block_size > 0) {
91 s->block_samples =
s->block_size;
92 s->mid =
av_calloc(
s->block_samples * 2,
sizeof(*
s->mid));
93 for (
int i = 0;
i < 3;
i++) {
94 s->side[
i] =
av_calloc(
s->block_samples * 2,
sizeof(*
s->side[0]));
106 for (
int i = 0, j = nb_samples - 1;
i < nb_samples;
i++, j--)
112 double b0,
double b1,
double b2,
113 double a1,
double a2,
114 double *sw1,
double *sw2)
119 for (
int n = 0; n < nb_samples; n++) {
120 double side =
src[n];
121 double oside = side *
b0 + w1;
123 w1 =
b1 * side + w2 +
a1 * oside;
124 w2 =
b2 * side +
a2 * oside;
138 const double *
src = (
const double *)in->
data[0];
139 const double level_in =
s->level_in;
140 const double level_out =
s->level_out;
141 const double b0 =
s->b0;
142 const double b1 =
s->b1;
143 const double b2 =
s->b2;
144 const double a1 = -
s->a1;
145 const double a2 = -
s->a2;
160 dst = (
double *)
out->data[0];
165 if (
s->block_samples == 0) {
169 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
170 double mid = (
src[0] +
src[1]) * level_in * .5;
171 double side = (
src[0] -
src[1]) * level_in * .5;
172 double oside = side *
b0 + w1;
174 w1 =
b1 * side + w2 +
a1 * oside;
175 w2 =
b2 * side +
a2 * oside;
177 if (
ctx->is_disabled) {
181 dst[0] = (mid + oside) * level_out;
182 dst[1] = (mid - oside) * level_out;
189 const double *
src = (
const double *)in->
data[0];
190 double *ssrc =
s->side[1] +
s->block_samples;
191 double *msrc =
s->mid;
193 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
194 if (
ctx->is_disabled) {
198 dst[0] = (msrc[n] + ssrc[n]) * level_out;
199 dst[1] = (msrc[n] - ssrc[n]) * level_out;
203 double *mdst =
s->mid +
s->block_samples;
204 double *sdst =
s->side[0] +
s->block_samples;
205 double *ssrc =
s->side[0];
206 double *msrc =
s->mid;
210 for (
int n = 0; n <
out->nb_samples; n++,
src += 2) {
211 mdst[n] = (
src[0] +
src[1]) * level_in * .5;
212 sdst[n] = (
src[0] -
src[1]) * level_in * .5;
222 ssrc =
s->side[0] +
s->block_samples;
223 sdst =
s->side[1] +
s->block_samples;
236 src = (
const double *)in->
data[0];
238 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
239 if (
ctx->is_disabled) {
243 dst[0] = (msrc[n] + ssrc[n]) * level_out;
244 dst[1] = (msrc[n] - ssrc[n]) * level_out;
248 memmove(
s->mid,
s->mid +
s->block_samples,
249 s->block_samples *
sizeof(*
s->mid));
250 memmove(
s->side[0],
s->side[0] +
s->block_samples,
251 s->block_samples *
sizeof(*
s->side[0]));
254 if (
s->block_samples > 0) {
259 out->nb_samples =
s->nb_samples;
261 s->nb_samples = nb_samples;
287 if (
s->block_samples > 0) {
303 if (
s->block_samples > 0) {
322 char *res,
int res_len,
int flags)
338 for (
int i = 0;
i < 3;
i++)
342 #define OFFSET(x) offsetof(CrossfeedContext, x)
343 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
344 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
370 .priv_class = &crossfeed_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
A list of supported channel layouts.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
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
#define AV_CHANNEL_LAYOUT_STEREO
static int activate(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void reverse_samples(double *dst, const double *src, int nb_samples)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVFilterPad inputs[]
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.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
static int config_input(AVFilterLink *inlink)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static const AVOption crossfeed_options[]
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.
static void filter_samples(double *dst, const double *src, int nb_samples, double b0, double b1, double b2, double a1, double a2, double *sw1, double *sw2)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
static double b1(void *priv, double x, double y)
AVFILTER_DEFINE_CLASS(crossfeed)
static double a2(void *priv, double x, double y)
A filter pad used for either input or output.
const AVFilter ff_af_crossfeed
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int filter_frame(AVFilterLink *inlink, AVFrame *in, int eof)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
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.
An AVChannelLayout holds information about the channel layout of audio data.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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.
static double b2(void *priv, double x, double y)
FF_FILTER_FORWARD_WANTED(outlink, 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 layout
static int query_formats(AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
static av_cold void uninit(AVFilterContext *ctx)
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
void * av_calloc(size_t nmemb, size_t size)
@ AV_OPT_TYPE_INT
Underlying C type is int.
static const int16_t alpha[]
#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,...)
static double b0(void *priv, double x, double y)
static double a1(void *priv, double x, double y)
@ AV_SAMPLE_FMT_DBL
double
#define FILTER_QUERY_FUNC(func)
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.