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
fc0de1c0
Commit
fc0de1c0
authored
May 26, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showfreqs: switch to activate
parent
a9fa6b8e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
26 deletions
+48
-26
avf_showfreqs.c
libavfilter/avf_showfreqs.c
+48
-26
No files found.
libavfilter/avf_showfreqs.c
View file @
fc0de1c0
...
...
@@ -30,6 +30,7 @@
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "audio.h"
#include "filters.h"
#include "video.h"
#include "avfilter.h"
#include "internal.h"
...
...
@@ -439,45 +440,66 @@ static int plot_freqs(AVFilterLink *inlink, AVFrame *in)
return
ff_filter_frame
(
outlink
,
out
);
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
static
int
filter_frame
(
AVFilterLink
*
inlink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
ShowFreqsContext
*
s
=
ctx
->
priv
;
AVFrame
*
fin
=
NULL
;
int
consumed
=
0
;
int
ret
=
0
;
if
(
s
->
pts
==
AV_NOPTS_VALUE
)
s
->
pts
=
in
->
pts
-
av_audio_fifo_size
(
s
->
fifo
);
fin
=
ff_get_audio_buffer
(
inlink
,
s
->
win_size
);
if
(
!
fin
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
av_audio_fifo_write
(
s
->
fifo
,
(
void
**
)
in
->
extended_data
,
in
->
nb_samples
);
while
(
av_audio_fifo_size
(
s
->
fifo
)
>=
s
->
win_size
)
{
fin
=
ff_get_audio_buffer
(
inlink
,
s
->
win_size
);
if
(
!
fin
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
fin
->
pts
=
s
->
pts
;
s
->
pts
+=
s
->
hop_size
;
ret
=
av_audio_fifo_peek
(
s
->
fifo
,
(
void
**
)
fin
->
extended_data
,
s
->
win_size
);
if
(
ret
<
0
)
goto
fail
;
fin
->
pts
=
s
->
pts
+
consumed
;
consumed
+=
s
->
hop_size
;
ret
=
av_audio_fifo_peek
(
s
->
fifo
,
(
void
**
)
fin
->
extended_data
,
s
->
win_size
);
if
(
ret
<
0
)
goto
fail
;
ret
=
plot_freqs
(
inlink
,
fin
);
av_frame_free
(
&
fin
);
av_audio_fifo_drain
(
s
->
fifo
,
s
->
hop_size
);
if
(
ret
<
0
)
goto
fail
;
}
ret
=
plot_freqs
(
inlink
,
fin
);
av_frame_free
(
&
fin
);
av_audio_fifo_drain
(
s
->
fifo
,
s
->
hop_size
);
fail:
s
->
pts
=
AV_NOPTS_VALUE
;
av_frame_free
(
&
fin
);
av_frame_free
(
&
in
);
return
ret
;
}
static
int
activate
(
AVFilterContext
*
ctx
)
{
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
ShowFreqsContext
*
s
=
ctx
->
priv
;
AVFrame
*
in
=
NULL
;
int
ret
=
0
;
FF_FILTER_FORWARD_STATUS_BACK
(
outlink
,
inlink
);
if
(
av_audio_fifo_size
(
s
->
fifo
)
<
s
->
win_size
)
ret
=
ff_inlink_consume_samples
(
inlink
,
s
->
win_size
,
s
->
win_size
,
&
in
);
if
(
ret
<
0
)
return
ret
;
if
(
ret
>
0
)
{
av_audio_fifo_write
(
s
->
fifo
,
(
void
**
)
in
->
extended_data
,
in
->
nb_samples
);
if
(
s
->
pts
==
AV_NOPTS_VALUE
)
s
->
pts
=
in
->
pts
;
}
if
(
av_audio_fifo_size
(
s
->
fifo
)
>=
s
->
win_size
)
{
ret
=
filter_frame
(
inlink
);
if
(
ret
<=
0
)
return
ret
;
}
FF_FILTER_FORWARD_STATUS
(
inlink
,
outlink
);
FF_FILTER_FORWARD_WANTED
(
outlink
,
inlink
);
return
FFERROR_NOT_READY
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
ShowFreqsContext
*
s
=
ctx
->
priv
;
...
...
@@ -500,7 +522,6 @@ static const AVFilterPad showfreqs_inputs[] = {
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
filter_frame
=
filter_frame
,
},
{
NULL
}
};
...
...
@@ -521,6 +542,7 @@ AVFilter ff_avf_showfreqs = {
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
priv_size
=
sizeof
(
ShowFreqsContext
),
.
activate
=
activate
,
.
inputs
=
showfreqs_inputs
,
.
outputs
=
showfreqs_outputs
,
.
priv_class
=
&
showfreqs_class
,
...
...
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