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;
224 .p.priv_class = &haas_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 const AVOption haas_options[]
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static av_cold void uninit(AVFilterContext *ctx)
const FFFilter ff_af_haas
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_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
Public libavutil channel layout APIs header.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#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
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#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.
static const uint16_t mask[17]
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
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static AVFormatContext * ctx