Go to the documentation of this file.
71 double w0 = 2 *
M_PI * (1. -
s->range) * 2100 /
inlink->sample_rate;
74 alpha = sin(w0) / 2 * sqrt((
A + 1 /
A) * (1 /
s->slope - 1) + 2);
76 s->a0 = (
A + 1) + (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha;
77 s->a1 = -2 * ((
A - 1) + (
A + 1) * cos(w0));
78 s->a2 = (
A + 1) + (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha;
79 s->b0 =
A * ((
A + 1) - (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha);
80 s->b1 = 2 *
A * ((
A - 1) - (
A + 1) * cos(w0));
81 s->b2 =
A * ((
A + 1) - (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha);
89 if (
s->block_samples == 0 &&
s->block_size > 0) {
90 s->block_samples =
s->block_size;
91 s->mid =
av_calloc(
s->block_samples * 2,
sizeof(*
s->mid));
92 for (
int i = 0;
i < 3;
i++) {
93 s->side[
i] =
av_calloc(
s->block_samples * 2,
sizeof(*
s->side[0]));
105 for (
int i = 0, j = nb_samples - 1;
i < nb_samples;
i++, j--)
111 double b0,
double b1,
double b2,
112 double a1,
double a2,
113 double *sw1,
double *sw2)
118 for (
int n = 0; n < nb_samples; n++) {
119 double side =
src[n];
120 double oside = side *
b0 + w1;
122 w1 =
b1 * side + w2 +
a1 * oside;
123 w2 =
b2 * side +
a2 * oside;
137 const double *
src = (
const double *)in->
data[0];
138 const double level_in =
s->level_in;
139 const double level_out =
s->level_out;
140 const double b0 =
s->b0;
141 const double b1 =
s->b1;
142 const double b2 =
s->b2;
143 const double a1 = -
s->a1;
144 const double a2 = -
s->a2;
159 dst = (
double *)
out->data[0];
164 if (
s->block_samples == 0) {
168 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
169 double mid = (
src[0] +
src[1]) * level_in * .5;
170 double side = (
src[0] -
src[1]) * level_in * .5;
171 double oside = side *
b0 + w1;
173 w1 =
b1 * side + w2 +
a1 * oside;
174 w2 =
b2 * side +
a2 * oside;
176 if (
ctx->is_disabled) {
180 dst[0] = (mid + oside) * level_out;
181 dst[1] = (mid - oside) * level_out;
188 const double *
src = (
const double *)in->
data[0];
189 double *ssrc =
s->side[1] +
s->block_samples;
190 double *msrc =
s->mid;
192 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
193 if (
ctx->is_disabled) {
197 dst[0] = (msrc[n] + ssrc[n]) * level_out;
198 dst[1] = (msrc[n] - ssrc[n]) * level_out;
202 double *mdst =
s->mid +
s->block_samples;
203 double *sdst =
s->side[0] +
s->block_samples;
204 double *ssrc =
s->side[0];
205 double *msrc =
s->mid;
209 for (
int n = 0; n <
out->nb_samples; n++,
src += 2) {
210 mdst[n] = (
src[0] +
src[1]) * level_in * .5;
211 sdst[n] = (
src[0] -
src[1]) * level_in * .5;
221 ssrc =
s->side[0] +
s->block_samples;
222 sdst =
s->side[1] +
s->block_samples;
235 src = (
const double *)in->
data[0];
237 for (
int n = 0; n <
out->nb_samples; n++,
src += 2, dst += 2) {
238 if (
ctx->is_disabled) {
242 dst[0] = (msrc[n] + ssrc[n]) * level_out;
243 dst[1] = (msrc[n] - ssrc[n]) * level_out;
247 memmove(
s->mid,
s->mid +
s->block_samples,
248 s->block_samples *
sizeof(*
s->mid));
249 memmove(
s->side[0],
s->side[0] +
s->block_samples,
250 s->block_samples *
sizeof(*
s->side[0]));
253 if (
s->block_samples > 0) {
258 out->nb_samples =
s->nb_samples;
260 s->nb_samples = nb_samples;
286 if (
s->block_samples > 0) {
302 if (
s->block_samples > 0) {
321 char *res,
int res_len,
int flags)
337 for (
int i = 0;
i < 3;
i++)
341 #define OFFSET(x) offsetof(CrossfeedContext, x)
342 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
343 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
369 .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.
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).
#define FILTER_QUERY_FUNC(func)
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)
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.
#define FILTER_INPUTS(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)
static const int16_t alpha[]
#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,...)
static double b0(void *priv, double x, double y)
@ AV_SAMPLE_FMT_DBL
double
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.