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
377 .p.name =
"crossfeed",
379 .p.priv_class = &crossfeed_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
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)
static const AVOption crossfeed_options[]
static int config_input(AVFilterLink *inlink)
const FFFilter ff_af_crossfeed
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int filter_frame(AVFilterLink *inlink, AVFrame *in, int eof)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static void reverse_samples(double *dst, const double *src, int nb_samples)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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 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.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
int ff_inlink_queued_samples(AVFilterLink *link)
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
internal math functions header
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define AV_CHANNEL_LAYOUT_STEREO
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_DBL
double
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const int16_t alpha[]
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
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 FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
enum MovChannelLayoutTag * layouts
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
A link between two filters.
int sample_rate
samples per second
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static AVFormatContext * ctx
static double b1(void *priv, double x, double y)
static double b2(void *priv, double x, double y)
static double b0(void *priv, double x, double y)
static double a2(void *priv, double x, double y)
static double a1(void *priv, double x, double y)