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
6af67dcc
Commit
6af67dcc
authored
Mar 01, 2019
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_astats: add support for optimized min/max/peak calculation
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
5cc4b79b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
af_astats.c
libavfilter/af_astats.c
+21
-5
No files found.
libavfilter/af_astats.c
View file @
6af67dcc
...
...
@@ -49,6 +49,8 @@
#define MEASURE_ZERO_CROSSINGS_RATE (1 << 17)
#define MEASURE_NUMBER_OF_SAMPLES (1 << 18)
#define MEASURE_MINMAXPEAK (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL)
typedef
struct
ChannelStats
{
double
last
;
double
last_non_zero
;
...
...
@@ -216,6 +218,14 @@ static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRat
depth
->
num
++
;
}
static
inline
void
update_minmax
(
AudioStatsContext
*
s
,
ChannelStats
*
p
,
double
d
)
{
if
(
d
<
p
->
min
)
p
->
min
=
d
;
if
(
d
>
p
->
max
)
p
->
max
=
d
;
}
static
inline
void
update_stat
(
AudioStatsContext
*
s
,
ChannelStats
*
p
,
double
d
,
double
nd
,
int64_t
i
)
{
if
(
d
<
p
->
min
)
{
...
...
@@ -406,26 +416,32 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
set_meta
(
metadata
,
0
,
"Overall.Number_of_samples"
,
"%f"
,
nb_samples
/
s
->
nb_channels
);
}
#define UPDATE_STATS_P(type,
double_sample, normalized_sample, int_sample)
\
#define UPDATE_STATS_P(type,
update_func, channel_func)
\
for (int c = 0; c < channels; c++) { \
ChannelStats *p = &s->chstats[c]; \
const type *src = (const type *)data[c]; \
const type * const srcend = src + samples; \
for (; src < srcend; src++) \
update_stat(s, p, double_sample, normalized_sample, int_sample); \
update_func; \
channel_func; \
}
#define UPDATE_STATS_I(type,
double_sample, normalized_sample, int_sample)
\
#define UPDATE_STATS_I(type,
update_func, channel_func)
\
for (int c = 0; c < channels; c++) { \
ChannelStats *p = &s->chstats[c]; \
const type *src = (const type *)data[0]; \
const type * const srcend = src + samples * channels; \
for (src += c; src < srcend; src += channels) \
update_stat(s, p, double_sample, normalized_sample, int_sample); \
update_func; \
channel_func; \
}
#define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \
UPDATE_STATS_##planar(type, sample, sample normalizer_suffix, int_sample);
if ((s->measure_overall | s->measure_perchannel) & ~MEASURE_MINMAXPEAK) { \
UPDATE_STATS_##planar(type, update_stat(s, p, sample, sample normalizer_suffix, int_sample), ); \
} else { \
UPDATE_STATS_##planar(type, update_minmax(s, p, sample), p->nmin = p->min normalizer_suffix; p->nmax = p->max normalizer_suffix;); \
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
buf
)
{
...
...
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