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
acc2347c
Commit
acc2347c
authored
Nov 29, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_agate: prepare for adding sidechain version
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
46db068c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
26 deletions
+33
-26
af_agate.c
libavfilter/af_agate.c
+33
-26
No files found.
libavfilter/af_agate.c
View file @
acc2347c
...
...
@@ -149,46 +149,29 @@ static double output_gain(double lin_slope, double ratio, double thres,
return
1
.;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
static
void
gate
(
AudioGateContext
*
s
,
const
double
*
src
,
double
*
dst
,
const
double
*
scsrc
,
int
nb_samples
,
AVFilterLink
*
inlink
,
AVFilterLink
*
sclink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AudioGateContext
*
s
=
ctx
->
priv
;
const
double
*
src
=
(
const
double
*
)
in
->
data
[
0
];
const
double
makeup
=
s
->
makeup
;
const
double
attack_coeff
=
s
->
attack_coeff
;
const
double
release_coeff
=
s
->
release_coeff
;
const
double
level_in
=
s
->
level_in
;
AVFrame
*
out
;
double
*
dst
;
int
n
,
c
;
if
(
av_frame_is_writable
(
in
))
{
out
=
in
;
}
else
{
out
=
ff_get_audio_buffer
(
inlink
,
in
->
nb_samples
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
}
dst
=
(
double
*
)
out
->
data
[
0
];
for
(
n
=
0
;
n
<
in
->
nb_samples
;
n
++
,
src
+=
inlink
->
channels
,
dst
+=
inlink
->
channels
)
{
double
abs_sample
=
fabs
(
src
[
0
]),
gain
=
1
.
0
;
for
(
n
=
0
;
n
<
nb_samples
;
n
++
,
src
+=
inlink
->
channels
,
dst
+=
inlink
->
channels
,
scsrc
+=
sclink
->
channels
)
{
double
abs_sample
=
fabs
(
scsrc
[
0
]),
gain
=
1
.
0
;
for
(
c
=
0
;
c
<
inlink
->
channels
;
c
++
)
dst
[
c
]
=
src
[
c
]
*
level_in
;
if
(
s
->
link
==
1
)
{
for
(
c
=
1
;
c
<
in
link
->
channels
;
c
++
)
abs_sample
=
FFMAX
(
fabs
(
src
[
c
]),
abs_sample
);
for
(
c
=
1
;
c
<
sc
link
->
channels
;
c
++
)
abs_sample
=
FFMAX
(
fabs
(
s
cs
rc
[
c
]),
abs_sample
);
}
else
{
for
(
c
=
1
;
c
<
in
link
->
channels
;
c
++
)
abs_sample
+=
fabs
(
src
[
c
]);
for
(
c
=
1
;
c
<
sc
link
->
channels
;
c
++
)
abs_sample
+=
fabs
(
s
cs
rc
[
c
]);
abs_sample
/=
in
link
->
channels
;
abs_sample
/=
sc
link
->
channels
;
}
if
(
s
->
detection
)
...
...
@@ -203,6 +186,30 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
for
(
c
=
0
;
c
<
inlink
->
channels
;
c
++
)
dst
[
c
]
*=
gain
*
makeup
;
}
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
const
double
*
src
=
(
const
double
*
)
in
->
data
[
0
];
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AudioGateContext
*
s
=
ctx
->
priv
;
AVFrame
*
out
;
double
*
dst
;
if
(
av_frame_is_writable
(
in
))
{
out
=
in
;
}
else
{
out
=
ff_get_audio_buffer
(
inlink
,
in
->
nb_samples
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
}
dst
=
(
double
*
)
out
->
data
[
0
];
gate
(
s
,
src
,
dst
,
src
,
in
->
nb_samples
,
inlink
,
inlink
);
if
(
out
!=
in
)
av_frame_free
(
&
in
);
...
...
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