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
e2a39b10
Commit
e2a39b10
authored
Aug 18, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showvolume: use current peak value for picking colors
parent
b3c6e89d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
filters.texi
doc/filters.texi
+3
-0
avf_showvolume.c
libavfilter/avf_showvolume.c
+5
-3
No files found.
doc/filters.texi
View file @
e2a39b10
...
...
@@ -16899,6 +16899,9 @@ The expression can use the following variables:
@item VOLUME
Current max volume of channel in dB.
@item PEAK
Current peak.
@item CHANNEL
Current channel number, starting from 0.
@end table
...
...
libavfilter/avf_showvolume.c
View file @
e2a39b10
...
...
@@ -31,8 +31,8 @@
#include "video.h"
#include "internal.h"
static
const
char
*
const
var_names
[]
=
{
"VOLUME"
,
"CHANNEL"
,
NULL
};
enum
{
VAR_VOLUME
,
VAR_CHANNEL
,
VAR_VARS_NB
};
static
const
char
*
const
var_names
[]
=
{
"VOLUME"
,
"CHANNEL"
,
"PEAK"
,
NULL
};
enum
{
VAR_VOLUME
,
VAR_CHANNEL
,
VAR_
PEAK
,
VAR_
VARS_NB
};
typedef
struct
ShowVolumeContext
{
const
AVClass
*
class
;
...
...
@@ -61,7 +61,7 @@ static const AVOption showvolume_options[] = {
{
"w"
,
"set channel width"
,
OFFSET
(
w
),
AV_OPT_TYPE_INT
,
{.
i64
=
400
},
80
,
8192
,
FLAGS
},
{
"h"
,
"set channel height"
,
OFFSET
(
h
),
AV_OPT_TYPE_INT
,
{.
i64
=
20
},
1
,
900
,
FLAGS
},
{
"f"
,
"set fade"
,
OFFSET
(
f
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
95
},
0
.
001
,
1
,
FLAGS
},
{
"c"
,
"set volume color expression"
,
OFFSET
(
color
),
AV_OPT_TYPE_STRING
,
{.
str
=
"
if(gte(VOLUME,-6), if(gte(VOLUME,-2), if(gte(VOLUME,-1), if(gt(VOLUME,0), 0xff0000ff, 0xff0066ff), 0xff00ffff),0xff00ff00),0xffff0000)
"
},
0
,
0
,
FLAGS
},
{
"c"
,
"set volume color expression"
,
OFFSET
(
color
),
AV_OPT_TYPE_STRING
,
{.
str
=
"
PEAK*255+floor((1-PEAK)*255)*256
"
},
0
,
0
,
FLAGS
},
{
"t"
,
"display channel names"
,
OFFSET
(
draw_text
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"v"
,
"display volume value"
,
OFFSET
(
draw_volume
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"o"
,
"set orientation"
,
OFFSET
(
orientation
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"orientation"
},
...
...
@@ -228,6 +228,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
for
(
i
=
0
;
i
<
insamples
->
nb_samples
;
i
++
)
max
=
FFMAX
(
max
,
src
[
i
]);
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_PEAK
]
=
max
;
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_VOLUME
]
=
20
.
0
*
log10
(
max
);
max
=
av_clipf
(
max
,
0
,
1
);
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_CHANNEL
]
=
c
;
...
...
@@ -258,6 +259,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
for
(
i
=
0
;
i
<
insamples
->
nb_samples
;
i
++
)
max
=
FFMAX
(
max
,
src
[
i
]);
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_PEAK
]
=
max
;
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_VOLUME
]
=
20
.
0
*
log10
(
max
);
max
=
av_clipf
(
max
,
0
,
1
);
s
->
values
[
c
*
VAR_VARS_NB
+
VAR_CHANNEL
]
=
c
;
...
...
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