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
12791ec5
Commit
12791ec5
authored
Jul 19, 2017
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_astats: measure dynamic range
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
cb13f448
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
filters.texi
doc/filters.texi
+4
-0
af_astats.c
libavfilter/af_astats.c
+7
-0
No files found.
doc/filters.texi
View file @
12791ec5
...
...
@@ -1623,6 +1623,7 @@ Crest_factor
Flat_factor
Peak_count
Bit_depth
Dynamic_range
and for Overall:
DC_offset
...
...
@@ -1697,6 +1698,9 @@ Number of occasions (not the number of samples) that the signal attained either
@item Bit depth
Overall bit depth of audio. Number of bits used for each sample.
@item Dynamic range
Measured dynamic range of audio in dB.
@end table
@section atempo
...
...
libavfilter/af_astats.c
View file @
12791ec5
...
...
@@ -28,6 +28,7 @@
typedef
struct
ChannelStats
{
double
last
;
double
min_non_zero
;
double
sigma_x
,
sigma_x2
;
double
avg_sigma_x2
,
min_sigma_x2
,
max_sigma_x2
;
double
min
,
max
;
...
...
@@ -110,6 +111,7 @@ static void reset_stats(AudioStatsContext *s)
p
->
min
=
p
->
nmin
=
p
->
min_sigma_x2
=
DBL_MAX
;
p
->
max
=
p
->
nmax
=
p
->
max_sigma_x2
=
DBL_MIN
;
p
->
min_non_zero
=
DBL_MAX
;
p
->
min_diff
=
DBL_MAX
;
p
->
max_diff
=
DBL_MIN
;
p
->
sigma_x
=
0
;
...
...
@@ -178,6 +180,9 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
p
->
min_runs
+=
p
->
min_run
*
p
->
min_run
;
}
if
(
d
!=
0
&&
FFABS
(
d
)
<
p
->
min_non_zero
)
p
->
min_non_zero
=
FFABS
(
d
);
if
(
d
>
p
->
max
)
{
p
->
max
=
d
;
p
->
nmax
=
nd
;
...
...
@@ -286,6 +291,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
bit_depth
(
s
,
p
->
mask
,
p
->
imask
,
&
depth
);
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
,
0
,
"Overall.DC_offset"
,
"%f"
,
max_sigma_x
/
(
nb_samples
/
s
->
nb_channels
));
...
...
@@ -479,6 +485,7 @@ static void print_stats(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_INFO
,
"Peak count: %"
PRId64
"
\n
"
,
p
->
min_count
+
p
->
max_count
);
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
,
"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