From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7F26E420C3 for ; Tue, 22 Feb 2022 16:45:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1160768B113; Tue, 22 Feb 2022 18:44:58 +0200 (EET) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B90E68AFF5 for ; Tue, 22 Feb 2022 18:44:51 +0200 (EET) Received: by mail-ej1-f48.google.com with SMTP id lw4so44735575ejb.12 for ; Tue, 22 Feb 2022 08:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AwCFkESSTNOXPeavdD0nWGGoMlupZAD5XqZK2ZgdfTA=; b=AKfTTiPsB3ljKGe2SBE9g6zcEyVY3epyUY7rEySd4nnFn836G2domf+dQEU2lkw0/C bcnL8QHMx88x/cJrtsaSyAFjhgEhj8KA3Kvf6xqOq4LxWmX4iirNp0Bqtd6jxE4++ezd k73BtZBdgQMEtHGWYUl14fSUu/rdFZTlpkEO1g1f8gOfuLswyFStGUV0p4J0n5/g2A/r YZUIb9NGYxH40SFAd6bcrHFBFNHr8rY8KulcKOirWZ7WDbddZkAfMAuSqb1E4qe24hk0 tMZGp+wap0GBLD61/apx3h4onUdSGHa5q7ktP9Iv4zfNxY33EDkVGVYDma0Hhgc3BCo2 W6YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AwCFkESSTNOXPeavdD0nWGGoMlupZAD5XqZK2ZgdfTA=; b=XwIb49o8PLRm1eLBEy88B/I2ZMiZny5lSYCJN8cp3I3+xa4pT6IGxpgMmPxSBvBBtU IU7xm07luzzVyQEmXE6D1Bkz4AkuIceQY1APMw2q3jZY7jH7l78r+Cce1ORn4CxjO7qV Dt3jEGUWFg3Pk+dZfmAHjhxiNXad5eYLwm4aLa5OGh2bmw2brNo016DQdwLoYaRlJPvu 8iUbi7znY8BGXQBdXSYErp2dfJexCx5qnpCA225IgvE1/KIasapZCnxYaVMO4dGoKziF FU1tAtE7g+DGPm7FAm2Ct8fcpl9lRt48g8UEjypqAP9OOcxqoClPJXQxfcEGFrH6bnFL LTaQ== X-Gm-Message-State: AOAM531tgn9/WCrJVMtjO07liSvX9LxRatap5R+GzboGDmyDeS3ar1Qe KkjCvQptZcIilkG0EvL3NDqdlqhzAeg= X-Google-Smtp-Source: ABdhPJwWhGIqKrGpLSfORuaqR5H2OPxEHmkhz3hUUSTEleX8o65aGipkdbURp2+BUFFKt6emCrgmCQ== X-Received: by 2002:a17:906:fac4:b0:6ce:ea4:a153 with SMTP id lu4-20020a170906fac400b006ce0ea4a153mr19449920ejb.411.1645548290660; Tue, 22 Feb 2022 08:44:50 -0800 (PST) Received: from localhost.localdomain ([212.15.177.16]) by smtp.gmail.com with ESMTPSA id g11sm6635938ejs.14.2022.02.22.08.44.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 08:44:50 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Feb 2022 17:46:15 +0100 Message-Id: <20220222164616.511012-2-onemda@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220222164616.511012-1-onemda@gmail.com> References: <20220222164616.511012-1-onemda@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avfilter/af_loudnorm: stop rewritting pts 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Paul B Mahol --- libavfilter/af_loudnorm.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index 5b4b6e8548..7c8ac3a39d 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -86,7 +86,7 @@ typedef struct LoudNormContext { int attack_length; int release_length; - int64_t pts; + int64_t pts[30]; enum FrameType frame_type; int above_threshold; int prev_nb_samples; @@ -432,10 +432,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) av_frame_copy_props(out, in); } - if (s->pts == AV_NOPTS_VALUE) - s->pts = in->pts; + out->pts = s->pts[0]; + memmove(s->pts, &s->pts[1], (FF_ARRAY_ELEMS(s->pts) - 1) * sizeof(s->pts[0])); - out->pts = s->pts; src = (const double *)in->data[0]; dst = (double *)out->data[0]; buf = s->buf; @@ -502,7 +501,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) true_peak_limiter(s, dst, subframe_length, inlink->channels); ff_ebur128_add_frames_double(s->r128_out, dst, subframe_length); - s->pts += out->nb_samples = subframe_length; s->frame_type = INNER_FRAME; @@ -567,7 +565,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (s->index >= 30) s->index -= 30; s->prev_nb_samples = in->nb_samples; - s->pts += in->nb_samples; break; case FINAL_FRAME: @@ -625,13 +622,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) dst = (double *)out->data[0]; ff_ebur128_add_frames_double(s->r128_out, dst, in->nb_samples); - s->pts += in->nb_samples; break; } if (in != out) av_frame_free(&in); - return ff_filter_frame(outlink, out); } @@ -706,8 +701,17 @@ static int activate(AVFilterContext *ctx) if (ret < 0) return ret; - if (ret > 0) + if (ret > 0) { + if (s->frame_type == FIRST_FRAME) { + const int nb_samples = frame_size(inlink->sample_rate, 100); + + for (int i = 0; i < FF_ARRAY_ELEMS(s->pts); i++) + s->pts[i] = in->pts + i * nb_samples; + } else { + s->pts[29] = in->pts; + } ret = filter_frame(inlink, in); + } if (ret < 0) return ret; @@ -789,7 +793,6 @@ static int config_input(AVFilterLink *inlink) init_gaussian_filter(s); - s->pts = AV_NOPTS_VALUE; s->buf_index = s->prev_buf_index = s->limiter_buf_index = 0; -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".