Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
9bebad86
Commit
9bebad86
authored
May 15, 2017
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_stereotools: introduce different balance modes
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
88896c46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
5 deletions
+66
-5
filters.texi
doc/filters.texi
+17
-0
af_stereotools.c
libavfilter/af_stereotools.c
+49
-5
No files found.
doc/filters.texi
View file @
9bebad86
...
...
@@ -3669,6 +3669,23 @@ Set S/C level. Default is 1. Allowed range is from 1 to 100.
@item phase
Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
@item bmode_in, bmode_out
Set balance mode for balance_in/balance_out option.
Can be one of the following:
@table @samp
@item balance
Classic balance mode. Attenuate one channel at time.
Gain is raised up to 1.
@item amplitude
Similar as classic mode above but gain is raised up to 2.
@item power
Equal power distribution, from -6dB to +6dB range.
@end table
@end table
@subsection Examples
...
...
libavfilter/af_stereotools.c
View file @
9bebad86
...
...
@@ -33,6 +33,8 @@ typedef struct StereoToolsContext {
int
phase_l
;
int
phase_r
;
int
mode
;
int
bmode_in
;
int
bmode_out
;
double
slev
;
double
sbal
;
double
mlev
;
...
...
@@ -83,6 +85,11 @@ static const AVOption stereotools_options[] = {
{
"delay"
,
"set delay"
,
OFFSET
(
delay
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
},
-
20
,
20
,
A
},
{
"sclevel"
,
"set S/C level"
,
OFFSET
(
sc_level
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
1
,
100
,
A
},
{
"phase"
,
"set stereo phase"
,
OFFSET
(
phase
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
},
0
,
360
,
A
},
{
"bmode_in"
,
"set balance in mode"
,
OFFSET
(
bmode_in
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
2
,
A
,
"bmode"
},
{
"balance"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
A
,
"bmode"
},
{
"amplitude"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
A
,
"bmode"
},
{
"power"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
2
},
0
,
0
,
A
,
"bmode"
},
{
"bmode_out"
,
"set balance out mode"
,
OFFSET
(
bmode_out
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
2
,
A
,
"bmode"
},
{
NULL
}
};
...
...
@@ -167,13 +174,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
dst
=
(
double
*
)
out
->
data
[
0
];
for
(
n
=
0
;
n
<
in
->
nb_samples
;
n
++
,
src
+=
2
,
dst
+=
2
)
{
double
L
=
src
[
0
],
R
=
src
[
1
],
l
,
r
,
m
,
S
;
double
L
=
src
[
0
],
R
=
src
[
1
],
l
,
r
,
m
,
S
,
gl
,
gr
,
gd
;
L
*=
level_in
;
R
*=
level_in
;
L
*=
1
.
-
FFMAX
(
0
.,
balance_in
);
R
*=
1
.
+
FFMIN
(
0
.,
balance_in
);
gl
=
1
.
-
FFMAX
(
0
.,
balance_in
);
gr
=
1
.
+
FFMIN
(
0
.,
balance_in
);
switch
(
s
->
bmode_in
)
{
case
1
:
gd
=
gl
-
gr
;
gl
=
1
.
+
gd
;
gr
=
1
.
-
gd
;
break
;
case
2
:
if
(
balance_in
<
0
.)
{
gr
=
FFMAX
(
0
.
5
,
gr
);
gl
=
1
.
/
gr
;
}
else
if
(
balance_in
>
0
.)
{
gl
=
FFMAX
(
0
.
5
,
gl
);
gr
=
1
.
/
gl
;
}
break
;
}
L
*=
gl
;
R
*=
gr
;
if
(
s
->
softclip
)
{
R
=
s
->
inv_atan_shape
*
atan
(
R
*
sc_level
);
...
...
@@ -253,8 +278,27 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
s
->
pos
=
(
s
->
pos
+
2
)
%
s
->
length
;
L
*=
1
.
-
FFMAX
(
0
.,
balance_out
);
R
*=
1
.
+
FFMIN
(
0
.,
balance_out
);
gl
=
1
.
-
FFMAX
(
0
.,
balance_out
);
gr
=
1
.
+
FFMIN
(
0
.,
balance_out
);
switch
(
s
->
bmode_out
)
{
case
1
:
gd
=
gl
-
gr
;
gl
=
1
.
+
gd
;
gr
=
1
.
-
gd
;
break
;
case
2
:
if
(
balance_out
<
0
.)
{
gr
=
FFMAX
(
0
.
5
,
gr
);
gl
=
1
.
/
gr
;
}
else
if
(
balance_out
>
0
.)
{
gl
=
FFMAX
(
0
.
5
,
gl
);
gr
=
1
.
/
gl
;
}
break
;
}
L
*=
gl
;
R
*=
gr
;
L
*=
level_out
;
R
*=
level_out
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment