Go to the documentation of this file.
27 #define MAX_HAAS_DELAY 40
56 #define OFFSET(x) offsetof(HaasContext, x)
57 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
63 {
"middle_source",
"set middle source",
OFFSET(par_m_source),
AV_OPT_TYPE_INT, {.i64=2}, 0, 3,
A,
"source" },
102 size_t new_buf_size = 1;
104 while (new_buf_size < min_buf_size)
108 s->buffer =
av_calloc(new_buf_size,
sizeof(*
s->buffer));
112 s->buffer_size = new_buf_size;
115 s->delay[0] = (uint32_t)(
s->par_delay0 * 0.001 *
inlink->sample_rate);
116 s->delay[1] = (uint32_t)(
s->par_delay1 * 0.001 *
inlink->sample_rate);
118 s->phase0 =
s->par_phase0 ? 1.0 : -1.0;
119 s->phase1 =
s->par_phase1 ? 1.0 : -1.0;
121 s->balance_l[0] = (
s->par_balance0 + 1) / 2 *
s->par_gain0 *
s->phase0;
122 s->balance_r[0] = (1.0 - (
s->par_balance0 + 1) / 2) * (
s->par_gain0) *
s->phase0;
123 s->balance_l[1] = (
s->par_balance1 + 1) / 2 *
s->par_gain1 *
s->phase1;
124 s->balance_r[1] = (1.0 - (
s->par_balance1 + 1) / 2) * (
s->par_gain1) *
s->phase1;
134 const double *
src = (
const double *)in->
data[0];
135 const double level_in =
s->level_in;
136 const double level_out =
s->level_out;
137 const uint32_t
mask =
s->buffer_size - 1;
153 dst = (
double *)
out->data[0];
156 double mid, side[2], side_l, side_r;
157 uint32_t s0_ptr, s1_ptr;
159 switch (
s->par_m_source) {
160 case 0: mid =
src[0];
break;
161 case 1: mid =
src[1];
break;
162 case 2: mid = (
src[0] +
src[1]) * 0.5;
break;
163 case 3: mid = (
src[0] -
src[1]) * 0.5;
break;
170 s0_ptr = (
s->write_ptr +
s->buffer_size -
s->delay[0]) &
mask;
171 s1_ptr = (
s->write_ptr +
s->buffer_size -
s->delay[1]) &
mask;
173 if (
s->par_middle_phase)
176 side[0] =
buffer[s0_ptr] *
s->par_side_gain;
177 side[1] =
buffer[s1_ptr] *
s->par_side_gain;
178 side_l = side[0] *
s->balance_l[0] - side[1] *
s->balance_l[1];
179 side_r = side[1] *
s->balance_r[1] - side[0] *
s->balance_r[0];
181 dst[0] = (mid + side_l) * level_out;
182 dst[1] = (mid + side_r) * level_out;
184 s->write_ptr = (
s->write_ptr + 1) &
mask;
220 .priv_class = &haas_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 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 ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int query_formats(AVFilterContext *ctx)
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.
#define FILTER_QUERY_FUNC(func)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_CH_LAYOUT_STEREO
A filter pad used for either input or output.
static const uint16_t mask[17]
#define FILTER_INPUTS(array)
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.
AVFILTER_DEFINE_CLASS(haas)
const AVFilter ff_af_haas
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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
int nb_samples
number of audio samples (per channel) described by this frame
static const AVFilterPad outputs[]
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
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
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad inputs[]
#define FILTER_OUTPUTS(array)
static const AVOption haas_options[]
@ AV_SAMPLE_FMT_DBL
double