From patchwork Tue Oct 9 12:32:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Molkentin X-Patchwork-Id: 10551 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:ab0:73d2:0:0:0:0:0 with SMTP id m18csp4843121uaq; Tue, 9 Oct 2018 05:33:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV620HB5N1Bd/VzP+LiPseDYH9/fn5zE3f0+hxcYWhqDwFHecedhP6V3ZkyTRt5LSiZ0niHGv X-Received: by 2002:a1c:1fcd:: with SMTP id f196-v6mr1815002wmf.19.1539088430134; Tue, 09 Oct 2018 05:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539088430; cv=none; d=google.com; s=arc-20160816; b=qntjZ2CBREbVQIEx/RydzGxY1EvEqLtiT6pdo2N19wx//KAhbHkZj10y3+mgfJ7ZSW J4UnZ+dg3G9f6bOiOQIBybEOw7P2VEK/obeGI+XGb3kYOf6mA3oLQui7rVKLnIuTInSn NEV1scGQLiwHMNsA0sctWYdn4ecnwKOSPUXPZ5YPRh6SZuKrgLrlqZ3Ac19IZW6fRku5 eWMwUe/8bF1fyS3r9WU7S+eiFUm1GdZ14YQD3DYKdcghZGcCAUrSHuQntj9o/5vIc3ij L9USsLpJm5mT1Z5nOaSweaUSAAUXq4y77GtM8e3IsXYJ2S8qIYJyTFwl3TedcG76dFaR zNlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=DnLbIQQ+u9LfJCkS3hf0Cl2RskMZf4QQP5llXs/H0uA=; b=uQXFK/7acnLJI1tX6EG34fyO1vO1paqnxD7DeYr+F/FIYeiR/ILRh/JX4qEk262wyK med1ZkkXGe8e5hKrmdZqW43T7fQMRx+s8tpnYbSZFjXDi2eB8ti272e2K7Jpt3EEZNAr VpzoP5t88IVpp7JC+cd0gbbVFWd7opZr/A7+QtIB1PAIV2KmkHiW5+QBDuM62CNajPV9 TMaCUpiEJuqO2wLuc36MubiCgkz1wlXT99PPlja7T6mOTV/VEvk10fhJ8Ehr1PwXgAFc SBX9Pxb19qxDtHO/nC6qWIvamsWQmmlNbm0pkAnabQdjc2gJJDzrPUpgsMbsAGOOxu0f qyfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 126-v6si10305264wmh.90.2018.10.09.05.33.49; Tue, 09 Oct 2018 05:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 74AC068A1CC; Tue, 9 Oct 2018 15:33:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.molkentin.net (mail.molkentin.net [138.201.121.149]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1F7068A180 for ; Tue, 9 Oct 2018 15:32:58 +0300 (EEST) Received: from localhost (localhost4.localdomain4 [127.0.0.1]) by mail.molkentin.net (Postfix) with ESMTP id 879F1DE1F5; Tue, 9 Oct 2018 14:33:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at example.com Received: from mail.molkentin.net ([127.0.0.1]) by localhost (mail.molkentin.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lopgwS_Nl_Mw; Tue, 9 Oct 2018 14:33:19 +0200 (CEST) Received: from oldnewthing.fritz.box (ip5b40eeb3.dynamic.kabel-deutschland.de [91.64.238.179]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: daniel@molkentin.de) by mail.molkentin.net (Postfix) with ESMTPSA id 4C405DE3F2; Tue, 9 Oct 2018 14:33:18 +0200 (CEST) From: Daniel Molkentin To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Oct 2018 14:32:55 +0200 Message-Id: <20181009123258.21222-4-daniel@molkentin.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181009123258.21222-1-daniel@molkentin.de> References: <20181009123258.21222-1-daniel@molkentin.de> Subject: [FFmpeg-devel] [PATCH 3/6] libavfilter/ebur128: add gauge option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Conrad Zelck , Daniel Molkentin MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allow to show short-term instead of momentary in gauge. Useful for monitoring whilst live mixing. Signed-off-by: Daniel Molkentin Signed-off-by: Conrad Zelck --- doc/filters.texi | 9 ++++++++- libavfilter/f_ebur128.c | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 86ea25bda8..7f2baed9b5 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -19281,7 +19281,8 @@ time graph to observe the loudness evolution. The graphic contains the logged message mentioned above, so it is not printed anymore when this option is set, unless the verbose logging is set. The main graphing area contains the short-term loudness (3 seconds of analysis), and the gauge on the right is for -the momentary loudness (400 milliseconds). +the momentary loudness (400 milliseconds), but can optionally be configured +to instead display short-term loudness (see @var{gauge}). More information about the Loudness Recommendation EBU R128 on @url{http://tech.ebu.ch/loudness}. @@ -19364,6 +19365,12 @@ Set a specific target level (in LUFS) used as relative zero in the visualization This parameter is optional and has a default value of -23LUFS as specified by EBU R128. However, material published online may prefer a level of -16LUFS (e.g. for use with podcasts or video platforms). + +@item gauge +Set the value displayed by the gauge. Valid values are @code{momentary} and s +@code{shortterm}. By default the momentary value will be used, but in certain +scenarios it may be more useful to observe the short term value instead (e.g. +live mixing). @end table @subsection Examples diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 89bfcb0b3e..c74dac94da 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -143,6 +143,7 @@ typedef struct EBUR128Context { int dual_mono; ///< whether or not to treat single channel input files as dual-mono double pan_law; ///< pan law value used to calculate dual-mono measurements int target; ///< target level in LUFS used to set relative zero LU in visualization + int gauge_type; ///< whether gauge shows momentary or short } EBUR128Context; enum { @@ -151,6 +152,12 @@ enum { PEAK_MODE_TRUE_PEAKS = 1<<2, }; +enum { + GAUGE_TYPE_MOMENTARY = 0, + GAUGE_TYPE_SHORTTERM = 1, +}; + + #define OFFSET(x) offsetof(EBUR128Context, x) #define A AV_OPT_FLAG_AUDIO_PARAM #define V AV_OPT_FLAG_VIDEO_PARAM @@ -170,6 +177,11 @@ static const AVOption ebur128_options[] = { { "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F }, { "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F }, { "target", "set a specific target level in LUFS (-23 to 0)", OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F }, + { "gauge", "set gauge display type", OFFSET(gauge_type), AV_OPT_TYPE_INT, {.i64 = 0 }, GAUGE_TYPE_MOMENTARY, GAUGE_TYPE_SHORTTERM, V|F, "gaugetype" }, + { "momentary", "display momentary value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" }, + { "m", "display momentary value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" }, + { "shortterm", "display short-term value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" }, + { "s", "display short-term value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" }, { NULL }, }; @@ -741,9 +753,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) if (ebur128->do_video) { int x, y, ret; uint8_t *p; + double gauge_value; + + if (ebur128->gauge_type == GAUGE_TYPE_MOMENTARY) { + gauge_value = loudness_400 - ebur128->target; + } else { + gauge_value = loudness_3000 - ebur128->target; + } const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->target); - const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400 - ebur128->target); + const int y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value); /* draw the graph using the short-term loudness */ p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3; @@ -755,7 +774,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) p += pic->linesize[0]; } - /* draw the gauge using the momentary loudness */ + /* draw the gauge using either momentary or short-term loudness */ p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] + ebur128->gauge.x*3; for (y = 0; y < ebur128->gauge.h; y++) { const uint8_t *c = get_graph_color(ebur128, y_loudness_lu_gauge, y);