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
bb54c0ae
Commit
bb54c0ae
authored
Oct 28, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_afftdn: switch to activate
parent
bdfd2e3c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
87 deletions
+116
-87
af_afftdn.c
libavfilter/af_afftdn.c
+116
-87
No files found.
libavfilter/af_afftdn.c
View file @
bb54c0ae
...
...
@@ -28,6 +28,7 @@
#include "avfilter.h"
#include "audio.h"
#include "formats.h"
#include "filters.h"
#define C (M_LN10 * 0.1)
#define RATIO 0.98
...
...
@@ -1153,7 +1154,7 @@ static void get_auto_noise_levels(AudioFFTDeNoiseContext *s,
}
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
static
int
output_frame
(
AVFilterLink
*
inlink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
...
...
@@ -1162,15 +1163,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
ThreadData
td
;
int
ret
=
0
;
if
(
s
->
pts
==
AV_NOPTS_VALUE
)
s
->
pts
=
frame
->
pts
;
ret
=
av_audio_fifo_write
(
s
->
fifo
,
(
void
**
)
frame
->
extended_data
,
frame
->
nb_samples
);
av_frame_free
(
&
frame
);
if
(
ret
<
0
)
return
ret
;
while
(
av_audio_fifo_size
(
s
->
fifo
)
>=
s
->
window_length
)
{
if
(
!
in
)
{
in
=
ff_get_audio_buffer
(
outlink
,
s
->
window_length
);
if
(
!
in
)
...
...
@@ -1179,7 +1171,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
ret
=
av_audio_fifo_peek
(
s
->
fifo
,
(
void
**
)
in
->
extended_data
,
s
->
window_length
);
if
(
ret
<
0
)
break
;
return
ret
;
if
(
s
->
track_noise
)
{
for
(
int
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
...
...
@@ -1233,7 +1225,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
out
=
ff_get_audio_buffer
(
outlink
,
s
->
sample_advance
);
if
(
!
out
)
{
ret
=
AVERROR
(
ENOMEM
);
break
;
goto
end
;
}
for
(
int
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
...
...
@@ -1267,14 +1259,51 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
out
->
pts
=
s
->
pts
;
ret
=
ff_filter_frame
(
outlink
,
out
);
if
(
ret
<
0
)
break
;
goto
end
;
s
->
pts
+=
s
->
sample_advance
;
}
end:
av_frame_free
(
&
in
);
return
ret
;
}
static
int
activate
(
AVFilterContext
*
ctx
)
{
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AudioFFTDeNoiseContext
*
s
=
ctx
->
priv
;
AVFrame
*
frame
=
NULL
;
int
ret
;
FF_FILTER_FORWARD_STATUS_BACK
(
outlink
,
inlink
);
ret
=
ff_inlink_consume_frame
(
inlink
,
&
frame
);
if
(
ret
<
0
)
return
ret
;
if
(
ret
>
0
)
{
if
(
s
->
pts
==
AV_NOPTS_VALUE
)
s
->
pts
=
frame
->
pts
;
ret
=
av_audio_fifo_write
(
s
->
fifo
,
(
void
**
)
frame
->
extended_data
,
frame
->
nb_samples
);
av_frame_free
(
&
frame
);
if
(
ret
<
0
)
return
ret
;
}
if
(
av_audio_fifo_size
(
s
->
fifo
)
>=
s
->
window_length
)
return
output_frame
(
inlink
);
FF_FILTER_FORWARD_STATUS
(
inlink
,
outlink
);
if
(
ff_outlink_frame_wanted
(
outlink
)
&&
av_audio_fifo_size
(
s
->
fifo
)
<
s
->
window_length
)
{
ff_inlink_request_frame
(
inlink
);
return
0
;
}
return
FFERROR_NOT_READY
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
AudioFFTDeNoiseContext
*
s
=
ctx
->
priv
;
...
...
@@ -1393,7 +1422,6 @@ static const AVFilterPad inputs[] = {
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
filter_frame
=
filter_frame
,
.
config_props
=
config_input
,
},
{
NULL
}
...
...
@@ -1413,6 +1441,7 @@ AVFilter ff_af_afftdn = {
.
query_formats
=
query_formats
,
.
priv_size
=
sizeof
(
AudioFFTDeNoiseContext
),
.
priv_class
=
&
afftdn_class
,
.
activate
=
activate
,
.
uninit
=
uninit
,
.
inputs
=
inputs
,
.
outputs
=
outputs
,
...
...
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