[FFmpeg-cvslog] avfilter/avf_showvolume: draw channel names directly into output frame

Paul B Mahol git at videolan.org
Sun Nov 19 00:44:14 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Nov 18 23:21:30 2023 +0100| [3ed2225a9d066ad1e4d83f46c9e721021f367f56] | committer: Paul B Mahol

avfilter/avf_showvolume: draw channel names directly into output frame

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ed2225a9d066ad1e4d83f46c9e721021f367f56
---

 libavfilter/avf_showvolume.c | 29 +++++++++++++++--------------
 1 file 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];



More information about the ffmpeg-cvslog mailing list