Go to the documentation of this file.
29 #define MAX_HAAS_DELAY 40
58 #define OFFSET(x) offsetof(HaasContext, x)
59 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
65 {
"middle_source",
"set middle source",
OFFSET(par_m_source),
AV_OPT_TYPE_INT, {.i64=2}, 0, 3,
A, .unit =
"source" },
114 size_t new_buf_size = 1;
116 while (new_buf_size < min_buf_size)
120 s->buffer =
av_calloc(new_buf_size,
sizeof(*
s->buffer));
124 s->buffer_size = new_buf_size;
127 s->delay[0] = (uint32_t)(
s->par_delay0 * 0.001 *
inlink->sample_rate);
128 s->delay[1] = (uint32_t)(
s->par_delay1 * 0.001 *
inlink->sample_rate);
130 s->phase0 =
s->par_phase0 ? 1.0 : -1.0;
131 s->phase1 =
s->par_phase1 ? 1.0 : -1.0;
133 s->balance_l[0] = (
s->par_balance0 + 1) / 2 *
s->par_gain0 *
s->phase0;
134 s->balance_r[0] = (1.0 - (
s->par_balance0 + 1) / 2) * (
s->par_gain0) *
s->phase0;
135 s->balance_l[1] = (
s->par_balance1 + 1) / 2 *
s->par_gain1 *
s->phase1;
136 s->balance_r[1] = (1.0 - (
s->par_balance1 + 1) / 2) * (
s->par_gain1) *
s->phase1;
146 const double *
src = (
const double *)in->
data[0];
147 const double level_in =
s->level_in;
148 const double level_out =
s->level_out;
149 const uint32_t
mask =
s->buffer_size - 1;
165 dst = (
double *)
out->data[0];
168 double mid, side[2], side_l, side_r;
169 uint32_t s0_ptr, s1_ptr;
171 switch (
s->par_m_source) {
172 case 0: mid =
src[0];
break;
173 case 1: mid =
src[1];
break;
174 case 2: mid = (
src[0] +
src[1]) * 0.5;
break;
175 case 3: mid = (
src[0] -
src[1]) * 0.5;
break;
182 s0_ptr = (
s->write_ptr +
s->buffer_size -
s->delay[0]) &
mask;
183 s1_ptr = (
s->write_ptr +
s->buffer_size -
s->delay[1]) &
mask;
185 if (
s->par_middle_phase)
188 side[0] =
buffer[s0_ptr] *
s->par_side_gain;
189 side[1] =
buffer[s1_ptr] *
s->par_side_gain;
190 side_l = side[0] *
s->balance_l[0] - side[1] *
s->balance_l[1];
191 side_r = side[1] *
s->balance_r[1] - side[0] *
s->balance_r[0];
193 dst[0] = (mid + side_l) * level_out;
194 dst[1] = (mid + side_r) * level_out;
196 s->write_ptr = (
s->write_ptr + 1) &
mask;
225 .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.
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
#define AV_CHANNEL_LAYOUT_STEREO
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
enum MovChannelLayoutTag * layouts
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 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.
A filter pad used for either input or output.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define FILTER_OUTPUTS(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 AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
const AVFilter ff_af_haas
#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
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int nb_samples
number of audio samples (per channel) described by this frame
AVSampleFormat
Audio sample formats.
#define FILTER_QUERY_FUNC2(func)
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
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
@ AV_OPT_TYPE_INT
Underlying C type is int.
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad inputs[]
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static const AVOption haas_options[]
@ AV_SAMPLE_FMT_DBL
double
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.