Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
c4774c54
Commit
c4774c54
authored
Sep 12, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_astats: count zero crossings
parent
acc9684d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
af_astats.c
libavfilter/af_astats.c
+12
-0
No files found.
libavfilter/af_astats.c
View file @
c4774c54
...
...
@@ -28,6 +28,7 @@
typedef
struct
ChannelStats
{
double
last
;
double
last_non_zero
;
double
min_non_zero
;
double
sigma_x
,
sigma_x2
;
double
avg_sigma_x2
,
min_sigma_x2
,
max_sigma_x2
;
...
...
@@ -40,6 +41,7 @@ typedef struct ChannelStats {
double
diff1_sum_x2
;
uint64_t
mask
,
imask
;
uint64_t
min_count
,
max_count
;
uint64_t
zero_runs
;
uint64_t
nb_samples
;
}
ChannelStats
;
...
...
@@ -127,6 +129,7 @@ static void reset_stats(AudioStatsContext *s)
p
->
imask
=
0xFFFFFFFFFFFFFFFF
;
p
->
min_count
=
0
;
p
->
max_count
=
0
;
p
->
zero_runs
=
0
;
p
->
nb_samples
=
0
;
}
}
...
...
@@ -196,6 +199,11 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
p
->
max_runs
+=
p
->
max_run
*
p
->
max_run
;
}
if
(
d
!=
0
)
{
p
->
zero_runs
+=
FFSIGN
(
d
)
!=
FFSIGN
(
p
->
last_non_zero
);
p
->
last_non_zero
=
d
;
}
p
->
sigma_x
+=
nd
;
p
->
sigma_x2
+=
nd
*
nd
;
p
->
avg_sigma_x2
=
p
->
avg_sigma_x2
*
s
->
mult
+
(
1
.
0
-
s
->
mult
)
*
nd
*
nd
;
...
...
@@ -292,6 +300,8 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
set_meta
(
metadata
,
c
+
1
,
"Bit_depth"
,
"%f"
,
depth
.
num
);
set_meta
(
metadata
,
c
+
1
,
"Bit_depth2"
,
"%f"
,
depth
.
den
);
set_meta
(
metadata
,
c
+
1
,
"Dynamic_range"
,
"%f"
,
LINEAR_TO_DB
(
2
*
FFMAX
(
FFABS
(
p
->
min
),
FFABS
(
p
->
max
))
/
p
->
min_non_zero
));
set_meta
(
metadata
,
c
+
1
,
"Zero_crossings"
,
"%f"
,
p
->
zero_runs
);
set_meta
(
metadata
,
c
+
1
,
"Zero_crossings_rate"
,
"%f"
,
p
->
zero_runs
/
(
double
)
p
->
nb_samples
);
}
set_meta
(
metadata
,
0
,
"Overall.DC_offset"
,
"%f"
,
max_sigma_x
/
(
nb_samples
/
s
->
nb_channels
));
...
...
@@ -486,6 +496,8 @@ static void print_stats(AVFilterContext *ctx)
bit_depth
(
s
,
p
->
mask
,
p
->
imask
,
&
depth
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Bit depth: %u/%u
\n
"
,
depth
.
num
,
depth
.
den
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Dynamic range: %f
\n
"
,
LINEAR_TO_DB
(
2
*
FFMAX
(
FFABS
(
p
->
min
),
FFABS
(
p
->
max
))
/
p
->
min_non_zero
));
av_log
(
ctx
,
AV_LOG_INFO
,
"Zero crossings: %"
PRId64
"
\n
"
,
p
->
zero_runs
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Zero crossings rate: %f
\n
"
,
p
->
zero_runs
/
(
double
)
p
->
nb_samples
);
}
av_log
(
ctx
,
AV_LOG_INFO
,
"Overall
\n
"
);
...
...
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