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
45b451c8
Commit
45b451c8
authored
Dec 06, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_alimiter: add 3 more options
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
b0669e7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
filters.texi
doc/filters.texi
+11
-2
af_alimiter.c
libavfilter/af_alimiter.c
+16
-7
No files found.
doc/filters.texi
View file @
45b451c8
...
...
@@ -833,9 +833,14 @@ that the delay it produces is the attack time you set.
The filter accepts the following options:
@table @option
@item level_in
Set input gain. Default is 1.
@item level_out
Set output gain. Default is 1.
@item limit
Don't let signals above this level pass the limiter. The removed amplitude is
added automatically. Default is 1.
Don't let signals above this level pass the limiter. Default is 1.
@item attack
The limiter will reach its attenuation level in this amount of time in
...
...
@@ -853,6 +858,10 @@ time.
@item asc_level
Select how much the release time is affected by ASC, 0 means nearly no changes
in release time while 1 produces higher release times.
@item level
Auto level output signal. Default is enabled.
This normalizes audio back to 0dB if enabled.
@end table
Depending on picked setting it is recommended to upsample input 2x or 4x times
...
...
libavfilter/af_alimiter.c
View file @
45b451c8
...
...
@@ -41,7 +41,10 @@ typedef struct AudioLimiterContext {
double
attack
;
double
release
;
double
att
;
double
level_in
;
double
level_out
;
int
auto_release
;
int
auto_level
;
double
asc
;
int
asc_c
;
int
asc_pos
;
...
...
@@ -64,11 +67,14 @@ typedef struct AudioLimiterContext {
#define F AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
alimiter_options
[]
=
{
{
"limit"
,
"set limit"
,
OFFSET
(
limit
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
.
0625
,
1
,
A
|
F
},
{
"attack"
,
"set attack"
,
OFFSET
(
attack
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
5
},
0
.
1
,
80
,
A
|
F
},
{
"release"
,
"set release"
,
OFFSET
(
release
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
50
},
1
,
8000
,
A
|
F
},
{
"asc"
,
"enable asc"
,
OFFSET
(
auto_release
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
A
|
F
},
{
"asc_level"
,
"set asc level"
,
OFFSET
(
asc_coeff
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
5
},
0
,
1
,
A
|
F
},
{
"level_in"
,
"set input level"
,
OFFSET
(
level_in
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},.
015625
,
64
,
A
|
F
},
{
"level_out"
,
"set output level"
,
OFFSET
(
level_out
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},.
015625
,
64
,
A
|
F
},
{
"limit"
,
"set limit"
,
OFFSET
(
limit
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
},
0
.
0625
,
1
,
A
|
F
},
{
"attack"
,
"set attack"
,
OFFSET
(
attack
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
5
},
0
.
1
,
80
,
A
|
F
},
{
"release"
,
"set release"
,
OFFSET
(
release
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
50
},
1
,
8000
,
A
|
F
},
{
"asc"
,
"enable asc"
,
OFFSET
(
auto_release
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
A
|
F
},
{
"asc_level"
,
"set asc level"
,
OFFSET
(
asc_coeff
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
5
},
0
,
1
,
A
|
F
},
{
"level"
,
"auto level"
,
OFFSET
(
auto_level
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
A
|
F
},
{
NULL
}
};
...
...
@@ -118,6 +124,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const
double
release
=
s
->
release
;
const
double
limit
=
s
->
limit
;
double
*
nextdelta
=
s
->
nextdelta
;
double
level
=
s
->
auto_level
?
1
/
limit
:
1
;
const
double
level_out
=
s
->
level_out
;
const
double
level_in
=
s
->
level_in
;
int
*
nextpos
=
s
->
nextpos
;
AVFrame
*
out
;
double
*
buf
;
...
...
@@ -139,7 +148,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
double
peak
=
0
;
for
(
c
=
0
;
c
<
channels
;
c
++
)
{
double
sample
=
src
[
c
];
double
sample
=
src
[
c
]
*
level_in
;
buffer
[
s
->
pos
+
c
]
=
sample
;
peak
=
FFMAX
(
peak
,
fabs
(
sample
));
...
...
@@ -255,7 +264,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
s
->
delta
=
0
.;
for
(
c
=
0
;
c
<
channels
;
c
++
)
dst
[
c
]
=
av_clipd
(
dst
[
c
],
-
limit
,
limit
);
dst
[
c
]
=
av_clipd
(
dst
[
c
],
-
limit
,
limit
)
*
level
*
level_out
;
s
->
pos
=
(
s
->
pos
+
channels
)
%
buffer_size
;
src
+=
channels
;
...
...
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