From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id A450F4E152 for ; Tue, 13 Jan 2026 15:27:57 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'/TPhnnCesXM9lrvwlEM93Ddap8ljRcxaI3QZIZSx580=', expected b'jVj089GgwhXMAIN22ffzb+/DxUsXsU6mGTCnQaN00+E=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1768318067; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=/TPhnnCesXM9lrvwlEM93Ddap8ljRcxaI3QZIZSx580=; b=eXADSIDIJW5qT43HXtOCFYmBFeRfpk28FygRsR/qmh5gQ9edFAda/EYJgFtbf/3Qs183+ nhlt1bFERlM80TCMGw5ELf5ir3cCcm2oy2YpkalNn4UZWu3/o8FpHkSEbcgxmzOW6W1U/OR nHn02Knhfvm6NM5kMCXWEXpb5y4JUPU/rIvCkseOwjm8+ESQge8TyTDiTcthCm9c90EXvPF mbgwVHpS94dA/1roLPc3WWZw93tchV5VEDnz3kRhem5u49A/So1sS64nUntE9OuktQLHL/Y i0gtSPGAUuiLm6/tpTVUrGHXVNGxaPzJIpqJJpnpea9R2KOAfAfat7V/FFmQ== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0F396690E05; Tue, 13 Jan 2026 17:27:47 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1768318052; b=sP97RFs0ngv3XXaV2iapWRI4rWaovYnXT/d2hryCCZuvNQmqCQQUlZ4yJ18DDB+vOdgKi YS7fLYaMxUNb7WOw+S8rrtDqyWHW48rOhc+cr75osufyiyVxqWc2voeCs+AHzBsaZcQjuFw Am63IxNlzxfnJmrSmeIh9aFWAC4XcaLUH6b1+VhlKuTDu8fNpOkojbYDiXKr/4Snl770cLL FHQUsZkqDGxdcSZKM1vjMeSeSUkLQLI4TxZ4uNdMzMoh6ZBEeoKIttaOR1Tzst1L7Ou6k9s vL4hshv3au7us/74UgH0sNMJO/eg76oLIMfT80NiJKhQtctyR9awHxPnlpVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1768318052; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=7WMpqOm02g2wfFS0K5EVc9N0HP3iBk1MO0G8dT9nhVI=; b=a1/6rwDrpz7DmY2NxYkkVDgjZoD0px13XmCj+JiWS14+UBkMshKnGcy2lfoS/o27pT9BU ZJxgifIv+ro3AQZojFpurd2P8J0HJIAq7mrqTz/YiAdARjPh07pCMutSUy5MHCPy5sDub/y IUZZJX1upBOyOp238tjA0Tj9df0X5SrMKDiB+HdI0SzkHD0hrAqz1RUXRNy5AbcJ8p7uvj7 2CdFbK3X3hbJiHychKEygdtRwLGOcz1yYe54SrCnuDWhUSz0IHEkILSKroFEwYZM2ykLxfG berIMPCQHp6cArGB2unZHBGLaKC57mEU73calCOa+FJc0rxqJOe9r40sb6Kw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1768318045; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=jVj089GgwhXMAIN22ffzb+/DxUsXsU6mGTCnQaN00+E=; b=TPRHmddzqIQ9nGYV1ya1RoIOHuWCvZPntP1vO9owSJfLDXBoPDi3BBOfRErSRfZEOisIS m7DFxMbNkI+yQ0dZHxKr3eXdPlyoiT0zsm0a3VCE9mXulwPt+VFZHiRz0XEez/FEP83uheb Au3DeRqx+UBCYoZUkp2yFHBO6iBeJIat5zvrU1tc67XV+TlCs69kQ46mv56Ielz7TCrek4L P9ctoSYt5SO7vID0wlDw6cGPR9MotKa76e9CQle31KCklisb8/m5Id/pco4ZKL3URoZyITb aEySzXhbSA44rzl9FsMeFhgcVDnrltKuT8Yyj0IljU7nsPD2wQFkTaX5f5Ug== Received: from f7c34508609e (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 9F30668D58A for ; Tue, 13 Jan 2026 17:27:25 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Jan 2026 15:27:25 -0000 Message-ID: <176831804580.25.9165504325125381743@4457048688e7> Message-ID-Hash: 5AD77IASRPWAE6AIU4JY7BLWKKGHXQPM X-Message-ID-Hash: 5AD77IASRPWAE6AIU4JY7BLWKKGHXQPM X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avfilter/af_loudnorm: fix slow gain ramp after initial silence (PR #21449) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: realies via ffmpeg-devel Cc: realies Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21449 opened by realies URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21449 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21449.patch ## Summary - Fixes fade-in artifact when audio begins with silence (3+ seconds) - When first 3s of audio is below `measured_thresh`, the filter set `above_threshold=0` - This caused gain to ramp at only 0.5 dB/second instead of applying correct gain immediately - Audio took 20+ seconds to reach steady state after silence ended ## Root Cause In INNER_FRAME processing with `above_threshold=0`: - Gain was increased via `prev_delta *= 1.0058` (~0.05 dB per 100ms) - `above_threshold` only changed to 1 when OUTPUT reached target - Created a catch-22: output couldn't reach target because gain was too low ## Fix When input short-term loudness exceeds `measured_thresh`, immediately transition to normal gain mode by: 1. Setting `above_threshold = 1` 2. Reinitializing all `delta[]` values with the correct gain This ensures proper gain is applied immediately when audio starts after silence. ## Test plan - [x] Tested with 11 different silence durations (0s to 10s) followed by constant tone - [x] All tests pass with fix (previously 5 failed with silence >= 3s) - [x] LUFS compliance tests pass - [x] True peak compliance tests pass - [x] Limiter and gating tests pass Fixes: https://github.com/slhck/ffmpeg-normalize/issues/146 >>From 5f0547f2e61cd472fc12715d301b2d608d11a945 Mon Sep 17 00:00:00 2001 From: realies Date: Tue, 13 Jan 2026 16:48:14 +0200 Subject: [PATCH] avfilter/af_loudnorm: fix slow gain ramp after initial silence When audio begins with silence (below measured_thresh), the filter would set above_threshold=0 and then slowly ramp up gain at only 0.5 dB/second when audio content started. This caused audible fade-in artifacts taking 20+ seconds to reach steady state. The bug was in the INNER_FRAME processing: when above_threshold=0, gain was increased via prev_delta *= 1.0058 (~0.05 dB per 100ms), and above_threshold only changed to 1 when OUTPUT reached target. This created a catch-22: output couldn't reach target because gain was too low. Fix: When input short-term loudness exceeds measured_thresh, immediately transition to normal gain mode by: 1. Setting above_threshold = 1 2. Reinitializing all delta[] values with the correct gain This ensures proper gain is applied immediately when audio starts after silence, rather than slowly ramping via Gaussian smoothing of stale values. Fixes fade-in artifacts reported in: - https://github.com/slhck/ffmpeg-normalize/issues/146 --- libavfilter/af_loudnorm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index 432b9710a5..5c047cb57d 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -543,14 +543,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ff_ebur128_relative_threshold(s->r128_in, &relative_threshold); if (s->above_threshold == 0) { - double shortterm_out; - - if (shortterm > s->measured_thresh) - s->prev_delta *= 1.0058; - - ff_ebur128_loudness_shortterm(s->r128_out, &shortterm_out); - if (shortterm_out >= s->target_i) + if (shortterm > s->measured_thresh) { + /* Input has exceeded threshold, transition to normal gain mode. + * Reinitialize all delta values with the correct gain to ensure + * immediate proper gain application when audio starts after + * silence, rather than slowly ramping up via Gaussian smoothing + * of stale values. */ + double env_st = s->target_i - shortterm; + double new_delta = pow(10., env_st / 20.); + for (int i = 0; i < 30; i++) + s->delta[i] = new_delta; + s->prev_delta = new_delta; s->above_threshold = 1; + } } if (shortterm < relative_threshold || shortterm <= -70. || s->above_threshold == 0) { -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org