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
a8536236
Commit
a8536236
authored
Oct 15, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_silenceremove: prefer outlink instead of inlink
parent
346b2323
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
af_silenceremove.c
libavfilter/af_silenceremove.c
+28
-28
No files found.
libavfilter/af_silenceremove.c
View file @
a8536236
...
@@ -321,31 +321,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -321,31 +321,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
switch
(
s
->
mode
)
{
switch
(
s
->
mode
)
{
case
SILENCE_TRIM
:
case
SILENCE_TRIM
:
silence_trim:
silence_trim:
nbs
=
in
->
nb_samples
-
nb_samples_read
/
in
link
->
channels
;
nbs
=
in
->
nb_samples
-
nb_samples_read
/
out
link
->
channels
;
if
(
!
nbs
)
if
(
!
nbs
)
break
;
break
;
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
if
(
s
->
start_mode
)
{
if
(
s
->
start_mode
)
{
threshold
=
0
;
threshold
=
0
;
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
}
}
}
else
{
}
else
{
threshold
=
1
;
threshold
=
1
;
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
start_threshold
;
}
}
}
}
if
(
threshold
)
{
if
(
threshold
)
{
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
s
->
update
(
s
,
*
ibuf
);
s
->
update
(
s
,
*
ibuf
);
s
->
start_holdoff
[
s
->
start_holdoff_end
++
]
=
*
ibuf
++
;
s
->
start_holdoff
[
s
->
start_holdoff_end
++
]
=
*
ibuf
++
;
}
}
nb_samples_read
+=
in
link
->
channels
;
nb_samples_read
+=
out
link
->
channels
;
if
(
s
->
start_holdoff_end
>=
s
->
start_duration
*
in
link
->
channels
)
{
if
(
s
->
start_holdoff_end
>=
s
->
start_duration
*
out
link
->
channels
)
{
if
(
++
s
->
start_found_periods
>=
s
->
start_periods
)
{
if
(
++
s
->
start_found_periods
>=
s
->
start_periods
)
{
s
->
mode
=
SILENCE_TRIM_FLUSH
;
s
->
mode
=
SILENCE_TRIM_FLUSH
;
goto
silence_trim_flush
;
goto
silence_trim_flush
;
...
@@ -359,19 +359,19 @@ silence_trim:
...
@@ -359,19 +359,19 @@ silence_trim:
}
else
{
}
else
{
s
->
start_holdoff_end
=
0
;
s
->
start_holdoff_end
=
0
;
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
s
->
update
(
s
,
ibuf
[
j
]);
s
->
update
(
s
,
ibuf
[
j
]);
if
(
s
->
start_silence
)
{
if
(
s
->
start_silence
)
{
s
->
start_silence_hold
[
s
->
start_silence_offset
++
]
=
ibuf
[
j
];
s
->
start_silence_hold
[
s
->
start_silence_offset
++
]
=
ibuf
[
j
];
s
->
start_silence_end
=
FFMIN
(
s
->
start_silence_end
+
1
,
in
link
->
channels
*
s
->
start_silence
);
s
->
start_silence_end
=
FFMIN
(
s
->
start_silence_end
+
1
,
out
link
->
channels
*
s
->
start_silence
);
if
(
s
->
start_silence_offset
>=
in
link
->
channels
*
s
->
start_silence
)
{
if
(
s
->
start_silence_offset
>=
out
link
->
channels
*
s
->
start_silence
)
{
s
->
start_silence_offset
=
0
;
s
->
start_silence_offset
=
0
;
}
}
}
}
}
}
ibuf
+=
in
link
->
channels
;
ibuf
+=
out
link
->
channels
;
nb_samples_read
+=
in
link
->
channels
;
nb_samples_read
+=
out
link
->
channels
;
}
}
}
}
break
;
break
;
...
@@ -379,11 +379,11 @@ silence_trim:
...
@@ -379,11 +379,11 @@ silence_trim:
case
SILENCE_TRIM_FLUSH
:
case
SILENCE_TRIM_FLUSH
:
silence_trim_flush:
silence_trim_flush:
nbs
=
s
->
start_holdoff_end
-
s
->
start_holdoff_offset
;
nbs
=
s
->
start_holdoff_end
-
s
->
start_holdoff_offset
;
nbs
-=
nbs
%
in
link
->
channels
;
nbs
-=
nbs
%
out
link
->
channels
;
if
(
!
nbs
)
if
(
!
nbs
)
break
;
break
;
out
=
ff_get_audio_buffer
(
inlink
,
nbs
/
inlink
->
channels
+
s
->
start_silence_end
/
in
link
->
channels
);
out
=
ff_get_audio_buffer
(
outlink
,
nbs
/
outlink
->
channels
+
s
->
start_silence_end
/
out
link
->
channels
);
if
(
!
out
)
{
if
(
!
out
)
{
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -428,11 +428,11 @@ silence_trim_flush:
...
@@ -428,11 +428,11 @@ silence_trim_flush:
case
SILENCE_COPY
:
case
SILENCE_COPY
:
silence_copy:
silence_copy:
nbs
=
in
->
nb_samples
-
nb_samples_read
/
in
link
->
channels
;
nbs
=
in
->
nb_samples
-
nb_samples_read
/
out
link
->
channels
;
if
(
!
nbs
)
if
(
!
nbs
)
break
;
break
;
out
=
ff_get_audio_buffer
(
in
link
,
nbs
);
out
=
ff_get_audio_buffer
(
out
link
,
nbs
);
if
(
!
out
)
{
if
(
!
out
)
{
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -443,12 +443,12 @@ silence_copy:
...
@@ -443,12 +443,12 @@ silence_copy:
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
for
(
i
=
0
;
i
<
nbs
;
i
++
)
{
if
(
s
->
stop_mode
)
{
if
(
s
->
stop_mode
)
{
threshold
=
0
;
threshold
=
0
;
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
threshold
|=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
}
}
}
else
{
}
else
{
threshold
=
1
;
threshold
=
1
;
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
threshold
&=
s
->
compute
(
s
,
ibuf
[
j
])
>
s
->
stop_threshold
;
}
}
}
}
...
@@ -458,28 +458,28 @@ silence_copy:
...
@@ -458,28 +458,28 @@ silence_copy:
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
,
0
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
,
0
);
goto
silence_copy_flush
;
goto
silence_copy_flush
;
}
else
if
(
threshold
)
{
}
else
if
(
threshold
)
{
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
s
->
update
(
s
,
*
ibuf
);
s
->
update
(
s
,
*
ibuf
);
*
obuf
++
=
*
ibuf
++
;
*
obuf
++
=
*
ibuf
++
;
}
}
nb_samples_read
+=
in
link
->
channels
;
nb_samples_read
+=
out
link
->
channels
;
nb_samples_written
+=
in
link
->
channels
;
nb_samples_written
+=
out
link
->
channels
;
}
else
if
(
!
threshold
)
{
}
else
if
(
!
threshold
)
{
for
(
j
=
0
;
j
<
in
link
->
channels
;
j
++
)
{
for
(
j
=
0
;
j
<
out
link
->
channels
;
j
++
)
{
s
->
update
(
s
,
*
ibuf
);
s
->
update
(
s
,
*
ibuf
);
if
(
s
->
stop_silence
)
{
if
(
s
->
stop_silence
)
{
s
->
stop_silence_hold
[
s
->
stop_silence_offset
++
]
=
*
ibuf
;
s
->
stop_silence_hold
[
s
->
stop_silence_offset
++
]
=
*
ibuf
;
s
->
stop_silence_end
=
FFMIN
(
s
->
stop_silence_end
+
1
,
in
link
->
channels
*
s
->
stop_silence
);
s
->
stop_silence_end
=
FFMIN
(
s
->
stop_silence_end
+
1
,
out
link
->
channels
*
s
->
stop_silence
);
if
(
s
->
stop_silence_offset
>=
in
link
->
channels
*
s
->
stop_silence
)
{
if
(
s
->
stop_silence_offset
>=
out
link
->
channels
*
s
->
stop_silence
)
{
s
->
stop_silence_offset
=
0
;
s
->
stop_silence_offset
=
0
;
}
}
}
}
s
->
stop_holdoff
[
s
->
stop_holdoff_end
++
]
=
*
ibuf
++
;
s
->
stop_holdoff
[
s
->
stop_holdoff_end
++
]
=
*
ibuf
++
;
}
}
nb_samples_read
+=
in
link
->
channels
;
nb_samples_read
+=
out
link
->
channels
;
if
(
s
->
stop_holdoff_end
>=
s
->
stop_duration
*
in
link
->
channels
)
{
if
(
s
->
stop_holdoff_end
>=
s
->
stop_duration
*
out
link
->
channels
)
{
if
(
++
s
->
stop_found_periods
>=
s
->
stop_periods
)
{
if
(
++
s
->
stop_found_periods
>=
s
->
stop_periods
)
{
s
->
stop_holdoff_offset
=
0
;
s
->
stop_holdoff_offset
=
0
;
s
->
stop_holdoff_end
=
0
;
s
->
stop_holdoff_end
=
0
;
...
@@ -509,7 +509,7 @@ silence_copy:
...
@@ -509,7 +509,7 @@ silence_copy:
}
}
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
,
0
);
flush
(
s
,
out
,
outlink
,
&
nb_samples_written
,
&
ret
,
0
);
}
else
{
}
else
{
memcpy
(
obuf
,
ibuf
,
sizeof
(
double
)
*
nbs
*
in
link
->
channels
);
memcpy
(
obuf
,
ibuf
,
sizeof
(
double
)
*
nbs
*
out
link
->
channels
);
out
->
pts
=
s
->
next_pts
;
out
->
pts
=
s
->
next_pts
;
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
s
->
next_pts
+=
av_rescale_q
(
out
->
nb_samples
,
...
@@ -523,11 +523,11 @@ silence_copy:
...
@@ -523,11 +523,11 @@ silence_copy:
case
SILENCE_COPY_FLUSH
:
case
SILENCE_COPY_FLUSH
:
silence_copy_flush:
silence_copy_flush:
nbs
=
s
->
stop_holdoff_end
-
s
->
stop_holdoff_offset
;
nbs
=
s
->
stop_holdoff_end
-
s
->
stop_holdoff_offset
;
nbs
-=
nbs
%
in
link
->
channels
;
nbs
-=
nbs
%
out
link
->
channels
;
if
(
!
nbs
)
if
(
!
nbs
)
break
;
break
;
out
=
ff_get_audio_buffer
(
inlink
,
nbs
/
in
link
->
channels
);
out
=
ff_get_audio_buffer
(
outlink
,
nbs
/
out
link
->
channels
);
if
(
!
out
)
{
if
(
!
out
)
{
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
...
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