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
376a3bdb
Commit
376a3bdb
authored
Nov 30, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_sidechaincompress: add level_in and level_sc options
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
a814f1d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
filters.texi
doc/filters.texi
+9
-0
af_sidechaincompress.c
libavfilter/af_sidechaincompress.c
+24
-17
No files found.
doc/filters.texi
View file @
376a3bdb
...
...
@@ -350,6 +350,9 @@ hard edge at the threshold in the range of the chosen decibels.
The filter accepts the following options:
@table @option
@item level_in
Set input gain. Default is 1. Range is between 0.015625 and 64.
@item threshold
If a signal of second stream rises above this level it will affect the gain
reduction of the first stream.
...
...
@@ -2479,6 +2482,9 @@ processing. See @ref{pan} and @ref{amerge} filter.
The filter accepts the following options:
@table @option
@item level_in
Set input gain. Default is 1. Range is between 0.015625 and 64.
@item threshold
If a signal of second stream raises above this level it will affect the gain
reduction of first stream.
...
...
@@ -2514,6 +2520,9 @@ reduction. Default is @code{average}.
Should the exact signal be taken in case of @code{peak} or an RMS one in case
of @code{rms}. Default is @code{rms} which is mainly smoother.
@item level_sc
Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
@item mix
How much to use compressed signal in output. Default is 1.
Range is between 0 and 1.
...
...
libavfilter/af_sidechaincompress.c
View file @
376a3bdb
...
...
@@ -38,6 +38,8 @@
typedef
struct
SidechainCompressContext
{
const
AVClass
*
class
;
double
level_in
;
double
level_sc
;
double
attack
,
attack_coeff
;
double
release
,
release_coeff
;
double
lin_slope
;
...
...
@@ -63,19 +65,21 @@ typedef struct SidechainCompressContext {
#define F AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
options
[]
=
{
{
"threshold"
,
"set threshold"
,
OFFSET
(
threshold
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
125
},
0
.
000
976563
,
1
,
A
|
F
},
{
"ratio"
,
"set ratio"
,
OFFSET
(
ratio
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
},
1
,
20
,
A
|
F
},
{
"attack"
,
"set attack"
,
OFFSET
(
attack
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
20
},
0
.
01
,
2000
,
A
|
F
},
{
"release"
,
"set release"
,
OFFSET
(
release
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
250
},
0
.
01
,
9000
,
A
|
F
},
{
"makeup"
,
"set make up gain"
,
OFFSET
(
makeup
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
},
1
,
64
,
A
|
F
},
{
"knee"
,
"set knee"
,
OFFSET
(
knee
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
.
82843
},
1
,
8
,
A
|
F
},
{
"link"
,
"set link type"
,
OFFSET
(
link
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
A
|
F
,
"link"
},
{
"average"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
A
|
F
,
"link"
},
{
"maximum"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
A
|
F
,
"link"
},
{
"detection"
,
"set detection"
,
OFFSET
(
detection
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
0
,
1
,
A
|
F
,
"detection"
},
{
"peak"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
A
|
F
,
"detection"
},
{
"rms"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
A
|
F
,
"detection"
},
{
"mix"
,
"set mix"
,
OFFSET
(
mix
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
,
1
,
A
|
F
},
{
"level_in"
,
"set input gain"
,
OFFSET
(
level_in
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
.
015625
,
64
,
A
|
F
},
{
"threshold"
,
"set threshold"
,
OFFSET
(
threshold
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
125
},
0
.
000
976563
,
1
,
A
|
F
},
{
"ratio"
,
"set ratio"
,
OFFSET
(
ratio
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
},
1
,
20
,
A
|
F
},
{
"attack"
,
"set attack"
,
OFFSET
(
attack
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
20
},
0
.
01
,
2000
,
A
|
F
},
{
"release"
,
"set release"
,
OFFSET
(
release
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
250
},
0
.
01
,
9000
,
A
|
F
},
{
"makeup"
,
"set make up gain"
,
OFFSET
(
makeup
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
},
1
,
64
,
A
|
F
},
{
"knee"
,
"set knee"
,
OFFSET
(
knee
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
2
.
82843
},
1
,
8
,
A
|
F
},
{
"link"
,
"set link type"
,
OFFSET
(
link
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
A
|
F
,
"link"
},
{
"average"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
A
|
F
,
"link"
},
{
"maximum"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
A
|
F
,
"link"
},
{
"detection"
,
"set detection"
,
OFFSET
(
detection
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
0
,
1
,
A
|
F
,
"detection"
},
{
"peak"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
A
|
F
,
"detection"
},
{
"rms"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
A
|
F
,
"detection"
},
{
"level_sc"
,
"set sidechain gain"
,
OFFSET
(
level_sc
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
.
015625
,
64
,
A
|
F
},
{
"mix"
,
"set mix"
,
OFFSET
(
mix
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
,
1
,
A
|
F
},
{
NULL
}
};
...
...
@@ -142,6 +146,7 @@ static int compressor_config_output(AVFilterLink *outlink)
static
void
compressor
(
SidechainCompressContext
*
s
,
double
*
sample
,
const
double
*
scsrc
,
int
nb_samples
,
double
level_in
,
double
level_sc
,
AVFilterLink
*
inlink
,
AVFilterLink
*
sclink
)
{
const
double
makeup
=
s
->
makeup
;
...
...
@@ -151,14 +156,14 @@ static void compressor(SidechainCompressContext *s,
for
(
i
=
0
;
i
<
nb_samples
;
i
++
)
{
double
abs_sample
,
gain
=
1
.
0
;
abs_sample
=
fabs
(
scsrc
[
0
]);
abs_sample
=
fabs
(
scsrc
[
0
]
*
level_sc
);
if
(
s
->
link
==
1
)
{
for
(
c
=
1
;
c
<
sclink
->
channels
;
c
++
)
abs_sample
=
FFMAX
(
fabs
(
scsrc
[
c
]),
abs_sample
);
abs_sample
=
FFMAX
(
fabs
(
scsrc
[
c
]
*
level_sc
),
abs_sample
);
}
else
{
for
(
c
=
1
;
c
<
sclink
->
channels
;
c
++
)
abs_sample
+=
fabs
(
scsrc
[
c
]);
abs_sample
+=
fabs
(
scsrc
[
c
]
*
level_sc
);
abs_sample
/=
sclink
->
channels
;
}
...
...
@@ -174,7 +179,7 @@ static void compressor(SidechainCompressContext *s,
s
->
compressed_knee_stop
,
s
->
detection
);
for
(
c
=
0
;
c
<
inlink
->
channels
;
c
++
)
sample
[
c
]
*=
(
gain
*
makeup
*
mix
+
(
1
.
-
mix
));
sample
[
c
]
*=
level_in
*
(
gain
*
makeup
*
mix
+
(
1
.
-
mix
));
sample
+=
inlink
->
channels
;
scsrc
+=
sclink
->
channels
;
...
...
@@ -208,6 +213,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
scsrc
=
(
const
double
*
)
s
->
input_frame
[
1
]
->
data
[
0
];
compressor
(
s
,
sample
,
scsrc
,
nb_samples
,
s
->
level_in
,
s
->
level_sc
,
ctx
->
inputs
[
0
],
ctx
->
inputs
[
1
]);
ret
=
ff_filter_frame
(
outlink
,
s
->
input_frame
[
0
]);
...
...
@@ -343,6 +349,7 @@ static int acompressor_filter_frame(AVFilterLink *inlink, AVFrame *frame)
sample
=
(
double
*
)
frame
->
data
[
0
];
compressor
(
s
,
sample
,
sample
,
frame
->
nb_samples
,
s
->
level_in
,
s
->
level_in
,
inlink
,
inlink
);
return
ff_filter_frame
(
outlink
,
frame
);
...
...
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