Go to the documentation of this file.
82 double w0 = 2 *
M_PI * (1. -
s->range) * 2100 /
inlink->sample_rate;
85 alpha = sin(w0) / 2 * sqrt((
A + 1 /
A) * (1 /
s->slope - 1) + 2);
87 s->a0 = (
A + 1) + (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha;
88 s->a1 = -2 * ((
A - 1) + (
A + 1) * cos(w0));
89 s->a2 = (
A + 1) + (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha;
90 s->b0 =
A * ((
A + 1) - (
A - 1) * cos(w0) + 2 * sqrt(
A) *
alpha);
91 s->b1 = 2 *
A * ((
A - 1) - (
A + 1) * cos(w0));
92 s->b2 =
A * ((
A + 1) - (
A - 1) * cos(w0) - 2 * sqrt(
A) *
alpha);
100 if (
s->block_samples == 0 &&
s->block_size > 0) {
101 s->block_samples =
s->block_size;
102 s->mid =
av_calloc(
s->block_samples * 2,
sizeof(*
s->mid));
103 for (
int i = 0;
i < 3;
i++) {
104 s->side[
i] =
av_calloc(
s->block_samples * 2,
sizeof(*
s->side[0]));
116 for (
int i = 0, j = nb_samples - 1;
i < nb_samples;
i++, j--)
122 double b0,
double b1,
double b2,
123 double a1,
double a2,
124 double *sw1,
double *sw2)
129 for (
int n = 0; n < nb_samples; n++) {
130 double side =
src[n];
131 double oside = side *
b0 + w1;
133 w1 =
b1 * side + w2 +
a1 * oside;
134 w2 =
b2 * side +
a2 * oside;
148 const double *
src = (
const double *)in->
data[0];
149 const double level_in =
s->level_in;
150 const double level_out =
s->level_out;
151 const double b0 =
s->b0;
152 const double b1 =
s->b1;
153 const double b2 =
s->b2;
154 const double a1 = -
s->a1;
155 const double a2 = -
s->a2;
170 dst = (
double *)
out->data[0];
175 if (
s->block_samples == 0) {
179 for (
int n = 0; n <
out->nb_samples; n++,
src += 2,
dst += 2) {
180 double mid = (
src[0] +
src[1]) * level_in * .5;
181 double side = (
src[0] -
src[1]) * level_in * .5;
182 double oside = side *
b0 + w1;
184 w1 =
b1 * side + w2 +
a1 * oside;
185 w2 =
b2 * side +
a2 * oside;
187 if (
ctx->is_disabled) {
191 dst[0] = (mid + oside) * level_out;
192 dst[1] = (mid - oside) * level_out;
199 const double *
src = (
const double *)in->
data[0];
200 double *ssrc =
s->side[1] +
s->block_samples;
201 double *msrc =
s->mid;
203 for (
int n = 0; n <
out->nb_samples; n++,
src += 2,
dst += 2) {
204 if (
ctx->is_disabled) {
208 dst[0] = (msrc[n] + ssrc[n]) * level_out;
209 dst[1] = (msrc[n] - ssrc[n]) * level_out;
213 double *mdst =
s->mid +
s->block_samples;
214 double *sdst =
s->side[0] +
s->block_samples;
215 double *ssrc =
s->side[0];
216 double *msrc =
s->mid;
220 for (
int n = 0; n <
out->nb_samples; n++,
src += 2) {
221 mdst[n] = (
src[0] +
src[1]) * level_in * .5;
222 sdst[n] = (
src[0] -
src[1]) * level_in * .5;
232 ssrc =
s->side[0] +
s->block_samples;
233 sdst =
s->side[1] +
s->block_samples;
246 src = (
const double *)in->
data[0];
248 for (
int n = 0; n <
out->nb_samples; n++,
src += 2,
dst += 2) {
249 if (
ctx->is_disabled) {
253 dst[0] = (msrc[n] + ssrc[n]) * level_out;
254 dst[1] = (msrc[n] - ssrc[n]) * level_out;
258 memmove(
s->mid,
s->mid +
s->block_samples,
259 s->block_samples *
sizeof(*
s->mid));
260 memmove(
s->side[0],
s->side[0] +
s->block_samples,
261 s->block_samples *
sizeof(*
s->side[0]));
264 if (
s->block_samples > 0) {
269 out->nb_samples =
s->nb_samples;
271 s->nb_samples = nb_samples;
297 if (
s->block_samples > 0) {
313 if (
s->block_samples > 0) {
332 char *res,
int res_len,
int flags)
348 for (
int i = 0;
i < 3;
i++)
352 #define OFFSET(x) offsetof(CrossfeedContext, x)
353 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
354 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
380 .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.
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.
enum MovChannelLayoutTag * layouts
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.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#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)
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)
AVSampleFormat
Audio sample formats.
#define FILTER_QUERY_FUNC2(func)
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[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
#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
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.