Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
7d0ce1e5
Commit
7d0ce1e5
authored
Oct 02, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_silencedetect: use the name 's' for the pointer to the private context
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
d49f3fa5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
af_silencedetect.c
libavfilter/af_silencedetect.c
+16
-17
No files found.
libavfilter/af_silencedetect.c
View file @
7d0ce1e5
...
...
@@ -62,17 +62,16 @@ static char *get_metadata_val(AVFrame *insamples, const char *key)
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
insamples
)
{
int
i
;
SilenceDetectContext
*
s
ilence
=
inlink
->
dst
->
priv
;
SilenceDetectContext
*
s
=
inlink
->
dst
->
priv
;
const
int
nb_channels
=
inlink
->
channels
;
const
int
srate
=
inlink
->
sample_rate
;
const
int
nb_samples
=
insamples
->
nb_samples
*
nb_channels
;
const
int64_t
nb_samples_notify
=
srate
*
s
ilence
->
duration
*
nb_channels
;
const
int64_t
nb_samples_notify
=
srate
*
s
->
duration
*
nb_channels
;
// scale number of null samples to the new sample rate
if
(
silence
->
last_sample_rate
&&
silence
->
last_sample_rate
!=
srate
)
silence
->
nb_null_samples
=
srate
*
silence
->
nb_null_samples
/
silence
->
last_sample_rate
;
silence
->
last_sample_rate
=
srate
;
if
(
s
->
last_sample_rate
&&
s
->
last_sample_rate
!=
srate
)
s
->
nb_null_samples
=
srate
*
s
->
nb_null_samples
/
s
->
last_sample_rate
;
s
->
last_sample_rate
=
srate
;
// TODO: support more sample formats
// TODO: document metadata
...
...
@@ -80,29 +79,29 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
double
*
p
=
(
double
*
)
insamples
->
data
[
0
];
for
(
i
=
0
;
i
<
nb_samples
;
i
++
,
p
++
)
{
if
(
*
p
<
s
ilence
->
noise
&&
*
p
>
-
silence
->
noise
)
{
if
(
!
s
ilence
->
start
)
{
s
ilence
->
nb_null_samples
++
;
if
(
s
ilence
->
nb_null_samples
>=
nb_samples_notify
)
{
s
ilence
->
start
=
insamples
->
pts
-
(
int64_t
)(
silence
->
duration
/
av_q2d
(
inlink
->
time_base
)
+
.
5
);
if
(
*
p
<
s
->
noise
&&
*
p
>
-
s
->
noise
)
{
if
(
!
s
->
start
)
{
s
->
nb_null_samples
++
;
if
(
s
->
nb_null_samples
>=
nb_samples_notify
)
{
s
->
start
=
insamples
->
pts
-
(
int64_t
)(
s
->
duration
/
av_q2d
(
inlink
->
time_base
)
+
.
5
);
av_dict_set
(
&
insamples
->
metadata
,
"lavfi.silence_start"
,
av_ts2timestr
(
s
ilence
->
start
,
&
inlink
->
time_base
),
0
);
av_log
(
s
ilence
,
AV_LOG_INFO
,
"silence_start: %s
\n
"
,
av_ts2timestr
(
s
->
start
,
&
inlink
->
time_base
),
0
);
av_log
(
s
,
AV_LOG_INFO
,
"silence_start: %s
\n
"
,
get_metadata_val
(
insamples
,
"lavfi.silence_start"
));
}
}
}
else
{
if
(
s
ilence
->
start
)
{
if
(
s
->
start
)
{
av_dict_set
(
&
insamples
->
metadata
,
"lavfi.silence_end"
,
av_ts2timestr
(
insamples
->
pts
,
&
inlink
->
time_base
),
0
);
av_dict_set
(
&
insamples
->
metadata
,
"lavfi.silence_duration"
,
av_ts2timestr
(
insamples
->
pts
-
s
ilence
->
start
,
&
inlink
->
time_base
),
0
);
av_log
(
s
ilence
,
AV_LOG_INFO
,
av_ts2timestr
(
insamples
->
pts
-
s
->
start
,
&
inlink
->
time_base
),
0
);
av_log
(
s
,
AV_LOG_INFO
,
"silence_end: %s | silence_duration: %s
\n
"
,
get_metadata_val
(
insamples
,
"lavfi.silence_end"
),
get_metadata_val
(
insamples
,
"lavfi.silence_duration"
));
}
s
ilence
->
nb_null_samples
=
silence
->
start
=
0
;
s
->
nb_null_samples
=
s
->
start
=
0
;
}
}
}
...
...
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