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
7760ed7e
Commit
7760ed7e
authored
May 15, 2017
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_silenceremove: set output timestamps
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
921bd9a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
af_silenceremove.c
libavfilter/af_silenceremove.c
+36
-6
No files found.
libavfilter/af_silenceremove.c
View file @
7760ed7e
...
...
@@ -217,11 +217,18 @@ static int config_input(AVFilterLink *inlink)
return
0
;
}
static
void
flush
(
AVFrame
*
out
,
AVFilterLink
*
outlink
,
static
void
flush
(
SilenceRemoveContext
*
s
,
AVFrame
*
out
,
AVFilterLink
*
outlink
,
int
*
nb_samples_written
,
int
*
ret
)
{
if
(
*
nb_samples_written
)
{
out
->
nb_samples
=
*
nb_samples_written
/
outlink
->
channels
;
out
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
*
ret
=
ff_filter_frame
(
outlink
,
out
);
*
nb_samples_written
=
0
;
}
else
{
...
...
@@ -297,6 +304,12 @@ silence_trim_flush:
memcpy
(
out
->
data
[
0
],
&
s
->
start_holdoff
[
s
->
start_holdoff_offset
],
nbs
*
sizeof
(
double
));
out
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
s
->
start_holdoff_offset
+=
nbs
;
ret
=
ff_filter_frame
(
outlink
,
out
);
...
...
@@ -330,7 +343,7 @@ silence_copy:
if
(
threshold
&&
s
->
stop_holdoff_end
&&
!
s
->
leave_silence
)
{
s
->
mode
=
SILENCE_COPY_FLUSH
;
flush
(
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
goto
silence_copy_flush
;
}
else
if
(
threshold
)
{
for
(
j
=
0
;
j
<
inlink
->
channels
;
j
++
)
{
...
...
@@ -358,7 +371,7 @@ silence_copy:
if
(
!
s
->
restart
)
{
s
->
mode
=
SILENCE_STOP
;
flush
(
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
goto
silence_stop
;
}
else
{
s
->
stop_found_periods
=
0
;
...
...
@@ -367,19 +380,25 @@ silence_copy:
s
->
start_holdoff_end
=
0
;
clear_window
(
s
);
s
->
mode
=
SILENCE_TRIM
;
flush
(
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
goto
silence_trim
;
}
}
s
->
mode
=
SILENCE_COPY_FLUSH
;
flush
(
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
goto
silence_copy_flush
;
}
}
}
flush
(
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
);
}
else
{
memcpy
(
obuf
,
ibuf
,
sizeof
(
double
)
*
nbs
*
inlink
->
channels
);
out
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
ret
=
ff_filter_frame
(
outlink
,
out
);
}
break
;
...
...
@@ -401,6 +420,11 @@ silence_copy_flush:
nbs
*
sizeof
(
double
));
s
->
stop_holdoff_offset
+=
nbs
;
out
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
ret
=
ff_filter_frame
(
outlink
,
out
);
if
(
s
->
stop_holdoff_offset
==
s
->
stop_holdoff_end
)
{
...
...
@@ -439,6 +463,12 @@ static int request_frame(AVFilterLink *outlink)
memcpy
(
frame
->
data
[
0
],
&
s
->
stop_holdoff
[
s
->
stop_holdoff_offset
],
nbs
*
sizeof
(
double
));
frame
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
frame
->
nb_samples
,
(
AVRational
){
1
,
outlink
->
sample_rate
},
outlink
->
time_base
);
ret
=
ff_filter_frame
(
ctx
->
inputs
[
0
],
frame
);
}
s
->
mode
=
SILENCE_STOP
;
...
...
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