From patchwork Sun Nov 19 06:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: shu coon X-Patchwork-Id: 44714 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp889700pzb; Sat, 18 Nov 2023 22:19:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9na5pChaAMx1Byl4zKikijPeuUd22xC+205XaTAAZf6A2e1yQaFHDBpIeLS7k1mYjTSDe X-Received: by 2002:a17:907:d409:b0:994:555a:e49f with SMTP id vi9-20020a170907d40900b00994555ae49fmr3949915ejc.31.1700374744606; Sat, 18 Nov 2023 22:19:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700374744; cv=none; d=google.com; s=arc-20160816; b=xZXs3/kyeo3yn11AvHH3CXMDAa7DZw6sJxwbQm2MTMs/wMeCaUJe37p4K0YIA2rNst TyyYnta4tKC2nzvoSSd7jBp9PZuF+61DKwh61RuYEu6FKclXx4K6pLCzEBbFH2va3Xe2 GEWA1uXvLzach2O1Mm3A3NXB/FGiGdFT1psJEsGgb9OAZWHpbeKKjsZBPzl0ojeAFDYk 4hPrke4pkAXCiirdbQdiqpp6kiR6wFP/32EUEblDFA/Df/ykWHeWR1ost1uvrzt2TQrg c1pCF7m6ouor/GIvbaFKjEcsX7OZ68/PpUOOx3BcRfYZoUCSSqKfJZfNEVZ+IrzfH+u1 NSxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:date:message-id:mime-version:from :dkim-signature:delivered-to; bh=x7hc+RYIPigukIjb68MirU4CbyDYi59p595lyz5/b5M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=s2QSvjTzfwqsH8m2778hjpqDhqlFoLk1m07Tq2LoUcll4fmq1ZJO2qXqo6vVsWS9Eb YOWgPphCHad3oX1kfp4qcL7a2KOUZeQC6EmvEb7Yyx6hM3nyt+GwKUNULi19FFEXvR+T as88d8HOJFD3+WH+SZt2LXRenE7RM1QPVni5jfoqC3hEZTfTK8aqzgUECVU4AQjQyhgn Yt1mkxC7+h3CAoOSc+BWFrXHlquaA8hBAiYpyU2NxJLJvm3qG5zlGbLEkHaoEhGueW1q 9byqnXf2s4Ymj6EaW86t0qFRhUsSE/ZBxGOK0Js4W7bQjEB8IYGQSCXo3OboG+zv0onW R1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=LJTenRIM; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f5-20020a170906048500b009a1e1f413a0si3175811eja.102.2023.11.18.22.19.03; Sat, 18 Nov 2023 22:19:04 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=LJTenRIM; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C470068CA45; Sun, 19 Nov 2023 08:18:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 780AF68C987 for ; Sun, 19 Nov 2023 08:18:53 +0200 (EET) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-da3b4b7c6bdso3253184276.2 for ; Sat, 18 Nov 2023 22:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700374731; x=1700979531; darn=ffmpeg.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=oXKYrGcqyfnojsvSiPrFRCdKmKQOmFuQ1rVg5NrlE/A=; b=LJTenRIMqBFilFZo5q6n5Fs3kixN5sXYnilE40CJ1r/O1AeAkGX2Tq0FZEYvZ1CLEr MeArdz943wluD1g6rKNLZfdopHx0jM2yuvpOEMjTsnLFdyc4Wro7yaQrT6bpKGVecKpi /PK1yiTv+mH4XZz9Qm5aEPCNVcWIkwGyMkOewXOya7uwU8LuynefnLNR6ZtaiMpMGzKK kiSpfkhUBecMUMXSt410eMP8+InurFJt3x4ckdKuBiI59940fUUbt32bJffKRBFkxHqy WO301J+cFYMrLsw1TW3a6yySyfvrf5joPvGhr4xT9rvX5DQXjv41u7XTwZiUdx2YLEBI 45Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700374731; x=1700979531; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oXKYrGcqyfnojsvSiPrFRCdKmKQOmFuQ1rVg5NrlE/A=; b=iHLwTR5Tt4CYK7idvD8rKYcc80vQ6mW2/gbIi+HoU8GLhL/gbsNjRLxtBAvmUZb3yC wAAiW6kJmgEkAs07qq8wfLvWA1qpLgp3nVd8Rqw9W7ExBxopPJmiLdVTKREsEu5otDD3 ltdweQgxP2dPPGqrEyg6yQ2xfo/zny56E+9z98sQeg4yVAbMwyAkpapT4XUR3YncQC4N 9fjDDkma1M8KUU7TdhuhWmt4pATVBqh84Jhegax/qnP0M/UyiMPNrtozp5M5tJ5JDxcD IASwI8yAN47FhYllPQ4m7piX+F59eSBPzyQKWBKDHFLC3KzQMgiL4BoNDNbAXnmL5DCd xEWg== X-Gm-Message-State: AOJu0YzP7UAzxybDbTpHdS3dceGMYALD24mji7rHO6MjEUfO8gUdym5R VJ0V5Sr1xewd3jfE5TPahmkSYg6c3/I= X-Received: by 2002:a25:ae18:0:b0:da0:4fba:1c61 with SMTP id a24-20020a25ae18000000b00da04fba1c61mr3921006ybj.46.1700374730913; Sat, 18 Nov 2023 22:18:50 -0800 (PST) Received: from smtpclient.apple ([209.9.115.69]) by smtp.gmail.com with ESMTPSA id c24-20020aa781d8000000b006bde2480806sm3787908pfn.47.2023.11.18.22.18.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 22:18:50 -0800 (PST) From: shu coon Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Message-Id: <74FC0A56-1A79-48BD-B146-516990C54944@gmail.com> Date: Sun, 19 Nov 2023 14:18:30 +0800 To: ffmpeg-devel@ffmpeg.org X-Mailer: Apple Mail (2.3731.600.7) X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] lavfilter/af_loudnorm: fix loudnorm limiter invalid at final frame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KsdVfhCEVXO5 Signed-off-by: 萧辰琨 --- libavfilter/af_loudnorm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index d83398ae2a..b8c10285ca 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -570,10 +570,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) case FINAL_FRAME: gain = gaussian_filter(s, s->index + 10 < 30 ? s->index + 10 : s->index + 10 - 30); - s->limiter_buf_index = 0; src_index = 0; - for (n = 0; n < s->limiter_buf_size / inlink->ch_layout.nb_channels; n++) { + subframe_length = frame_size(inlink->sample_rate, 100); + for (n = 0; n < subframe_length; n++) { for (c = 0; c < inlink->ch_layout.nb_channels; c++) { s->limiter_buf[s->limiter_buf_index + c] = src[src_index + c] * gain * s->offset; } @@ -658,6 +658,7 @@ static int flush_frame(AVFilterLink *outlink) offset = ((s->limiter_buf_size / inlink->ch_layout.nb_channels) - s->prev_nb_samples) * inlink->ch_layout.nb_channels; offset -= (frame_size(inlink->sample_rate, 100) - s->prev_nb_samples) * inlink->ch_layout.nb_channels; s->buf_index = s->buf_index - offset < 0 ? s->buf_index - offset + s->buf_size : s->buf_index - offset; + s->limiter_buf_index = s->limiter_buf_index - offset < 0 ? s->limiter_buf_index - offset + s->limiter_buf_size : s->limiter_buf_index - offset; for (n = 0; n < nb_samples; n++) { for (c = 0; c < inlink->ch_layout.nb_channels; c++) {