[FFmpeg-devel] [PATCH 1/2] lavfi/ebur128: add support for smaller video sizes

Marton Balint cus at passwd.hu
Sun Nov 16 22:53:15 CET 2014


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 doc/filters.texi        |  4 ++--
 libavfilter/f_ebur128.c | 11 ++++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 53f4cb2..713989c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10146,8 +10146,8 @@ activated. Default is @code{0}.
 
 @item size
 Set the video size. This option is for video only. For the syntax of this
-option, check the "Video size" section in the ffmpeg-utils manual. Default
-and minimum resolution is @code{640x480}.
+option, check the "Video size" section in the ffmpeg-utils manual. The default
+resolution is @code{640x480}, the minimum is @code{480x102}.
 
 @item meter
 Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index c18ae79..8780062 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -114,6 +114,7 @@ typedef struct {
     int scale_range;                ///< the range of LU values according to the meter
     int y_zero_lu;                  ///< the y value (pixel position) for 0 LU
     int *y_line_ref;                ///< y reference values for drawing the LU lines in the graph and the gauge
+    int line_step;                  ///< LU steps for drawn lines
 
     /* audio */
     int nb_channels;                ///< number of channels in the input
@@ -257,9 +258,9 @@ static int config_video_output(AVFilterLink *outlink)
     AVFrame *outpicref;
 
     /* check if there is enough space to represent everything decently */
-    if (ebur128->w < 640 || ebur128->h < 480) {
+    if (ebur128->w < 480 || ebur128->h < 102) {
         av_log(ctx, AV_LOG_ERROR, "Video size %dx%d is too small, "
-               "minimum size is 640x480\n", ebur128->w, ebur128->h);
+               "minimum size is 480x102\n", ebur128->w, ebur128->h);
         return AVERROR(EINVAL);
     }
     outlink->w = ebur128->w;
@@ -285,6 +286,9 @@ static int config_video_output(AVFilterLink *outlink)
     ebur128->graph.w = ebur128->gauge.x - ebur128->graph.x - PAD;
     ebur128->graph.h = ebur128->gauge.h;
 
+    /* compute line step based on graph height and needed lines */
+    ebur128->line_step = (ebur128->scale_range * 8 - 1) / (ebur128->graph.h) + 1;
+
     /* graph and gauge share the LU-to-pixel code */
     av_assert0(ebur128->graph.h == ebur128->gauge.h);
 
@@ -309,8 +313,9 @@ static int config_video_output(AVFilterLink *outlink)
     for (i = ebur128->meter; i >= -ebur128->meter * 2; i--) {
         y = lu_to_y(ebur128, i);
         x = PAD + (i < 10 && i > -10) * 8;
-        ebur128->y_line_ref[y] = i;
+        ebur128->y_line_ref[y] = ((i % ebur128->line_step == 0) ? i : 0);
         y -= 4; // -4 to center vertically
+        if (i % ebur128->line_step == 0)
         drawtext(outpicref, x, y + ebur128->graph.y, FONT8, font_colors+3,
                  "%c%d", i < 0 ? '-' : i > 0 ? '+' : ' ', FFABS(i));
     }
-- 
2.1.2



More information about the ffmpeg-devel mailing list