Go to the documentation of this file.
61 #define OFFSET(x) offsetof(StereoToolsContext, x)
62 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
94 {
"bmode_in",
"set balance in mode",
OFFSET(bmode_in),
AV_OPT_TYPE_INT, {.i64=0}, 0, 2,
A, .unit =
"bmode" },
98 {
"bmode_out",
"set balance out mode",
OFFSET(bmode_out),
AV_OPT_TYPE_INT, {.i64=0}, 0, 2,
A, .unit =
"bmode" },
114 { .nb_channels = 0 },
142 s->inv_atan_shape = 1.0 / atan(
s->sc_level);
143 s->phase_cos_coef = cos(
s->phase / 180 *
M_PI);
144 s->phase_sin_coef = sin(
s->phase / 180 *
M_PI);
154 const double *
src = (
const double *)in->
data[0];
155 const double sb =
s->base < 0 ?
s->base * 0.5 :
s->base;
156 const double sbal = 1 +
s->sbal;
157 const double mpan = 1 +
s->mpan;
158 const double slev =
s->slev;
159 const double mlev =
s->mlev;
160 const double balance_in =
s->balance_in;
161 const double balance_out =
s->balance_out;
162 const double level_in =
s->level_in;
163 const double level_out =
s->level_out;
164 const double sc_level =
s->sc_level;
165 const double delay =
s->delay;
166 const int length =
s->length;
167 const int mute_l =
s->mute_l;
168 const int mute_r =
s->mute_r;
169 const int phase_l =
s->phase_l;
170 const int phase_r =
s->phase_r;
174 int nbuf =
inlink->sample_rate * (
fabs(delay) / 1000.);
188 dst = (
double *)
out->data[0];
191 double L =
src[0],
R =
src[1], l,
r, m,
S, gl, gr, gd;
196 gl = 1. -
FFMAX(0., balance_in);
197 gr = 1. +
FFMIN(0., balance_in);
198 switch (
s->bmode_in) {
205 if (balance_in < 0.) {
208 }
else if (balance_in > 0.) {
218 R =
s->inv_atan_shape * atan(
R * sc_level);
219 L =
s->inv_atan_shape * atan(
L * sc_level);
226 l = m * mlev *
FFMIN(1., 2. - mpan) +
S * slev *
FFMIN(1., 2. - sbal);
227 r = m * mlev *
FFMIN(1., mpan) -
S * slev *
FFMIN(1., sbal);
232 l =
L *
FFMIN(1., 2. - sbal);
234 L = 0.5 * (l +
r) * mlev;
235 R = 0.5 * (l -
r) * slev;
238 l =
L * mlev *
FFMIN(1., 2. - mpan) +
R * slev *
FFMIN(1., 2. - sbal);
259 l = m * mlev *
FFMIN(1., 2. - mpan) +
S * slev *
FFMIN(1., 2. - sbal);
260 r = m * mlev *
FFMIN(1., mpan) -
S * slev *
FFMIN(1., sbal);
265 l =
L * mlev *
FFMIN(1., 2. - mpan) +
R * slev *
FFMIN(1., 2. - sbal);
275 l =
L * mlev *
FFMIN(1., 2. - mpan) +
R * slev *
FFMIN(1., 2. - sbal);
289 L *= (2. * (1. - phase_l)) - 1.;
290 R *= (2. * (1. - phase_r)) - 1.;
296 R =
buffer[(
s->pos - (int)nbuf + 1 + length) % length];
297 }
else if (delay < 0.) {
298 L =
buffer[(
s->pos - (int)nbuf + length) % length];
301 l =
L + sb *
L - sb *
R;
302 r =
R + sb *
R - sb *
L;
307 l =
L *
s->phase_cos_coef -
R *
s->phase_sin_coef;
308 r =
L *
s->phase_sin_coef +
R *
s->phase_cos_coef;
313 s->pos = (
s->pos + 2) %
s->length;
315 gl = 1. -
FFMAX(0., balance_out);
316 gr = 1. +
FFMIN(0., balance_out);
317 switch (
s->bmode_out) {
324 if (balance_out < 0.) {
327 }
else if (balance_out > 0.) {
340 if (
ctx->is_disabled) {
355 char *res,
int res_len,
int flags)
383 .
name =
"stereotools",
386 .priv_class = &stereotools_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
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.
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.
static __device__ float fabs(float a)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
#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 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 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)
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.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#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,...)
@ AV_SAMPLE_FMT_DBL
double
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.