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
9842d670
Commit
9842d670
authored
Jun 29, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showvolume: optionally display channel names
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
e55e5be9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
filters.texi
doc/filters.texi
+3
-0
avf_showvolume.c
libavfilter/avf_showvolume.c
+30
-0
No files found.
doc/filters.texi
View file @
9842d670
...
...
@@ -12023,6 +12023,9 @@ The expression can use the following variables:
@item VOLUME
Current max volume of channel in dB.
@end table
@item t
If set, displays channel names. Default is enabled.
@end table
@section showwaves
...
...
libavfilter/avf_showvolume.c
View file @
9842d670
...
...
@@ -23,6 +23,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/xga_font_data.h"
#include "avfilter.h"
#include "formats.h"
#include "audio.h"
...
...
@@ -38,6 +39,7 @@ typedef struct ShowVolumeContext {
AVFrame
*
out
;
AVExpr
*
c_expr
;
int
draw_text
;
}
ShowVolumeContext
;
#define OFFSET(x) offsetof(ShowVolumeContext, x)
...
...
@@ -51,6 +53,7 @@ static const AVOption showvolume_options[] = {
{
"h"
,
"set channel height"
,
OFFSET
(
h
),
AV_OPT_TYPE_INT
,
{.
i64
=
20
},
1
,
100
,
FLAGS
},
{
"f"
,
"set fade"
,
OFFSET
(
f
),
AV_OPT_TYPE_INT
,
{.
i64
=
20
},
1
,
255
,
FLAGS
},
{
"c"
,
"set volume color expression"
,
OFFSET
(
color
),
AV_OPT_TYPE_STRING
,
{.
str
=
"if(gte(VOLUME,-2), if(gte(VOLUME,-1),0xff, 0xffff),0xff00)"
},
0
,
0
,
FLAGS
},
{
"t"
,
"display channel names"
,
OFFSET
(
draw_text
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
NULL
}
};
...
...
@@ -133,6 +136,29 @@ static int config_output(AVFilterLink *outlink)
return
0
;
}
static
void
drawtext
(
AVFrame
*
pic
,
int
x
,
int
y
,
const
char
*
txt
)
{
const
uint8_t
*
font
;
int
font_height
;
int
i
;
font
=
avpriv_cga_font
,
font_height
=
8
;
for
(
i
=
0
;
txt
[
i
];
i
++
)
{
int
char_y
,
mask
;
uint8_t
*
p
=
pic
->
data
[
0
]
+
y
*
pic
->
linesize
[
0
]
+
(
x
+
i
*
8
)
*
4
;
for
(
char_y
=
0
;
char_y
<
font_height
;
char_y
++
)
{
for
(
mask
=
0x80
;
mask
;
mask
>>=
1
)
{
if
(
font
[
txt
[
i
]
*
font_height
+
char_y
]
&
mask
)
AV_WN32
(
p
,
~
AV_RN32
(
p
));
p
+=
4
;
}
p
+=
pic
->
linesize
[
0
]
-
8
*
4
;
}
}
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
insamples
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
...
...
@@ -183,6 +209,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
for
(
k
=
0
;
k
<
s
->
w
*
max
;
k
++
)
AV_WN32A
(
dst
+
k
*
4
,
color
);
}
if
(
s
->
h
>=
8
&&
s
->
draw_text
)
drawtext
(
s
->
out
,
2
,
c
*
(
s
->
h
+
s
->
b
)
+
(
s
->
h
-
8
)
/
2
,
av_get_channel_name
(
av_channel_layout_extract_channel
(
insamples
->
channel_layout
,
c
)));
}
av_frame_free
(
&
insamples
);
...
...
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