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;
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 .p.name =
"stereotools",
385 .p.priv_class = &stereotools_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)
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.
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.
Main libavfilter public API header.
#define flags(name, subs,...)
Public libavutil channel layout APIs header.
static float softclip(float value, float source, float target)
static __device__ float fabs(float a)
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 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
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.
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