summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-11-18 23:21:30 +0100
committerPaul B Mahol <onemda@gmail.com>2023-11-18 23:50:38 +0100
commit3ed2225a9d066ad1e4d83f46c9e721021f367f56 (patch)
tree12a37004614fcf271a07df3ff1a682fbec4ebbc4
parentfbc7adba6742c4d33ae525a72881f456281b4c46 (diff)
avfilter/avf_showvolume: draw channel names directly into output frame
-rw-r--r--libavfilter/avf_showvolume.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index fa64d5237a..b61f6c1d4f 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -379,13 +379,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
}
- if (s->h >= 8 && s->draw_text) {
- int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&insamples->ch_layout, c));
- if (ret < 0)
- continue;
- drawtext(s->out, c * (s->h + s->b) + (s->h - 10) / 2, outlink->h - 35, channel_name, 1);
- }
-
if (s->draw_persistent_duration > 0.) {
calc_persistent_max(s, max, c);
max_draw = FFMAX(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
@@ -415,13 +408,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
}
- if (s->h >= 8 && s->draw_text) {
- int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&insamples->ch_layout, c));
- if (ret < 0)
- continue;
- drawtext(s->out, 2, c * (s->h + s->b) + (s->h - 8) / 2, channel_name, 0);
- }
-
if (s->draw_persistent_duration > 0.) {
calc_persistent_max(s, max, c);
max_draw = FFMAX(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
@@ -440,6 +426,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
return ret;
}
+ /* draw channel names */
+ for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 10 && s->draw_text; c++) {
+ if (s->orientation) { /* vertical */
+ int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&inlink->ch_layout, c));
+ if (ret < 0)
+ continue;
+ drawtext(out, c * (s->h + s->b) + (s->h - 10) / 2, outlink->h - 35, channel_name, 1);
+ } else { /* horizontal */
+ int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&inlink->ch_layout, c));
+ if (ret < 0)
+ continue;
+ drawtext(out, 2, c * (s->h + s->b) + (s->h - 8) / 2, channel_name, 0);
+ }
+ }
+
/* draw volume level */
for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 8 && s->draw_volume; c++) {
char buf[16];