From patchwork Tue Oct 9 12:32:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Molkentin X-Patchwork-Id: 10561 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:ab0:73d2:0:0:0:0:0 with SMTP id m18csp4843515uaq; Tue, 9 Oct 2018 05:34:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61tzDOAs5yyyNYMtyUaL/TkFX3MwKKM0HzYEKSaGMrEHe8edNPFrl3EURbVM4qhhgEJtBmk X-Received: by 2002:a5d:6748:: with SMTP id l8-v6mr2959763wrw.197.1539088448648; Tue, 09 Oct 2018 05:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539088448; cv=none; d=google.com; s=arc-20160816; b=i7y3nnOagqwwyMN3W7F3rxWoZ6gDoI2dAVk+WtdIKnTSbCrZHdau/EXcR6KhB0y4ML +OmnCg+rwddu2S2TTUl/4lra6sSfzeqJwQuJ/JZtqVawDujftHiq4HZasv3EAHVZOYc4 EXU/kY2D3cZOK8uyMMOjBiOhxQvyQaKV5/NaGkZAlIWEpR5YbZXt1icC68rcuBgZnBmc 6NOvJ/ITdp4U/eHBN2r0Jm4DN231XDaaqBpVcXZ+ybXl5PzkBCV9Mzbc4mtTKyK2zfZR Pqj3H5JqIJ74Uru/KCKmkzM39I4yZbCPalSl8i2UIAWYqb3JGBanM4s/7wEJf15JQ2B0 N5DA== 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=OK/f/jjeZMWb8HDByjZTL1ySQR3jEofYSpkJTp2sShw=; b=vBvzQmY53N0w+zDexMCc/FX0pzcaUouOFUSozwuAd0jK8u2frWlIwhmbJZMQUtP1Fg QSaECipaoGdVuJC15OjsosizrmlVpAkyInBtDyHy4jJGXdzoowlbTr0rJkNshZnSWSjv 8H8KTWqJwjym6pH7137Co+H6ouaMBzoJ1CmB8DBgHmAws0Ww9V0iBy/fMOayJqc5Sz2h 4GC8kNTntfIIKMy6hYdoEWX4+VCTpQA6vGok2Rdze+bOfZQ2RcL27V+vp8ygDRNVFrKR +hkn07/PUo7AlyrUT5z07Jl9ilcVIf5WPlbMSPezNPiQLphkeKVUi6KVOoi7r4hXKqaj p0Mw== 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 c79-v6si12534788wmc.174.2018.10.09.05.34.08; Tue, 09 Oct 2018 05:34:08 -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 34D0E68A1A7; Tue, 9 Oct 2018 15:33:08 +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 6B09468A1A7 for ; Tue, 9 Oct 2018 15:33:01 +0300 (EEST) Received: from localhost (localhost4.localdomain4 [127.0.0.1]) by mail.molkentin.net (Postfix) with ESMTP id 4228CDE43B; Tue, 9 Oct 2018 14:33:23 +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 qozgLFXNTdbR; Tue, 9 Oct 2018 14:33:22 +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 191B6DE43A; Tue, 9 Oct 2018 14:33:20 +0200 (CEST) From: Daniel Molkentin To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Oct 2018 14:32:57 +0200 Message-Id: <20181009123258.21222-6-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 5/6] libavfilter/ebur128: add scale parameter 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" This allows switching between absolute (LUFS) and relativ (LU) display in the status line. Signed-off-by: Daniel Molkentin Signed-off-by: Conrad Zelck --- doc/filters.texi | 5 +++++ libavfilter/f_ebur128.c | 42 ++++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 3783a8a421..ceeee0e785 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -19374,6 +19374,11 @@ 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). + +@item scale +Sets the display scale for the loudness. Valid parameters are @code{absolute} +(in LUFS) or @code{relative} (LU) relative to the target. This only affects the +video output, not the summary or continuous log output. @end table @subsection Examples diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 688c7bf135..d481e479b0 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -146,6 +146,7 @@ typedef struct EBUR128Context { 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 + int scale; ///< display scale type of statistics } EBUR128Context; enum { @@ -159,6 +160,10 @@ enum { GAUGE_TYPE_SHORTTERM = 1, }; +enum { + SCALE_TYPE_ABSOLUTE = 0, + SCALE_TYPE_RELATIVE = 1, +}; #define OFFSET(x) offsetof(EBUR128Context, x) #define A AV_OPT_FLAG_AUDIO_PARAM @@ -184,6 +189,11 @@ static const AVOption ebur128_options[] = { { "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" }, + { "scale", "sets display method for the stats", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, V|F, "scaletype" }, + { "absolute", "display absolute values (LUFS)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, "scaletype" }, + { "LUFS", "display absolute values (LUFS)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, "scaletype" }, + { "relative", "display values relative to target (LU)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, "scaletype" }, + { "LU", "display values relative to target (LU)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, "scaletype" }, { NULL }, }; @@ -760,7 +770,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) loudness_3000 -= ebur128->pan_law; } -#define LOG_FMT "TARGET:%d M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f LU" +#define LOG_FMT "TARGET:%d LUFS M:%6.1f S:%6.1f I:%6.1f %s LRA:%6.1f LU" /* push one video frame */ if (ebur128->do_video) { @@ -798,10 +808,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) } /* draw textual info */ - drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors, - LOG_FMT " ", // padding to erase trailing characters - ebur128->target, loudness_400, loudness_3000, - ebur128->integrated_loudness, ebur128->loudness_range); + if (ebur128->scale == SCALE_TYPE_ABSOLUTE) { + drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors, + LOG_FMT " ", // padding to erase trailing characters + ebur128->target, loudness_400, loudness_3000, + ebur128->integrated_loudness, "LUFS", ebur128->loudness_range); + } else { + drawtext(pic, PAD, PAD - PAD/2, FONT16, font_colors, + LOG_FMT " ", // padding to erase trailing characters + ebur128->target, loudness_400-ebur128->target, loudness_3000-ebur128->target, + ebur128->integrated_loudness-ebur128->target, "LU", ebur128->loudness_range); + } /* set pts and push frame */ pic->pts = pts; @@ -841,10 +858,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) SET_META_PEAK(true, TRUE); } - av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT, - av_ts2timestr(pts, &outlink->time_base), - ebur128->target, loudness_400, loudness_3000, - ebur128->integrated_loudness, ebur128->loudness_range); + if (ebur128->scale == SCALE_TYPE_ABSOLUTE) { + av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT, + av_ts2timestr(pts, &outlink->time_base), + ebur128->target, loudness_400, loudness_3000, + ebur128->integrated_loudness, "LUFS", ebur128->loudness_range); + } else { + av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT, + av_ts2timestr(pts, &outlink->time_base), + ebur128->target, loudness_400-ebur128->target, loudness_3000-ebur128->target, + ebur128->integrated_loudness-ebur128->target, "LU", ebur128->loudness_range); + } #define PRINT_PEAKS(str, sp, ptype) do { \ if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \