From patchwork Mon Feb 12 09:48:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaullier Nicolas X-Patchwork-Id: 7565 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp3791819jai; Mon, 12 Feb 2018 01:48:45 -0800 (PST) X-Google-Smtp-Source: AH8x227pEi98qvV3opfFpVb2qz2rW7wrBoAmZUaVeuklfH8EnKn0PMErgX+TKCHpitLJgBeifI6H X-Received: by 10.28.172.70 with SMTP id v67mr3208811wme.58.1518428925406; Mon, 12 Feb 2018 01:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518428925; cv=none; d=google.com; s=arc-20160816; b=nHF5zCZCG5ct4HNOV3q6/F7VoHQNjxOxj6RBseS104xUgtKtcOiK/ETPDdQfAz/61J XSAJTrKP1rq0lJ8NEhSuOwPicevKdb8i2bPKYH2feCE+k88W/RxcozYZWpRfn0tMOIHX zjFilc8TuiobrodM6QdRbr7Fzu7RJyOD0D5s0Xmi+AnfCDqv1KOl5wq/MLQCWlWpgmzT U+BYUk+5afilaJpzxJeb1nzTUoZJ8ZfBloxXPBNVfkX+SL3/LxvTgk1htd+fEZly0XO8 Ck98PPVTw1Kull62FSKNhP3jk7x7Z/d+LCwEn7OdhDAqgwbw4hDXSwEzquIC/YgHqCk/ AxQQ== 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:dkim-signature:delivered-to:arc-authentication-results; bh=RpufLtEq4/nv25HA1brskfquMuPJQyMV1sO10EU9syk=; b=ZtgPHm9Y5WLWqjEMb5DaCa6R1EksFue+1OLK/jyk0P5EqIqHB5WoqUWqN+wpcM2ESB Z7oRZj3cCoX2BShbOP8HesX3V+0vH9r/DcOXL0JNjbESKky3VAg57TLCaMYTHM4j1Hpc GvOrZePHrGbLbPjPwdTvJPzL3vl1BGeevAU7/xNjNQqsVZQE0PlXsnczPOsuaiwBsVXH Vu/WamQoNqG/TV/HRIyEPpVA9xXOeY73G4kMa24JsR6H/cux0ko5X2uAL7ZMkZCCaLlu a7N3+V7cRxKbj+0r9TBC9QmwKs+4iKeT++E8wwEygBnIJor7en8cGKz+Va0XvrGHnl0b APpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@arkena.com header.s=20150421 header.b=uJXj8kfK; 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 p12si6123191wrg.493.2018.02.12.01.48.44; Mon, 12 Feb 2018 01:48:45 -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=@arkena.com header.s=20150421 header.b=uJXj8kfK; 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 5D9F8689A98; Mon, 12 Feb 2018 11:48:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp-1.arkena.net (smtp-1.arkena.net [95.81.173.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 48D376899F8 for ; Mon, 12 Feb 2018 11:48:26 +0200 (EET) Received: from secu2 (unknown [10.180.103.10]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-1.arkena.net (Postfix) with ESMTPSA id 3zg1841JgNzMcYf; Mon, 12 Feb 2018 09:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arkena.com; s=20150421; t=1518428916; bh=9UxMMz6JJabi97zciA86b3OfFibDvSO1u31MV76xtsk=; h=From:To:Cc:Subject:Date:Message-Id; b=uJXj8kfKKB9LbFSUcZP4X1qvHRegqvkpo2Osc0s2X0GcSU7nTGVObtNHBYhjUbmQK R3b/hU59mKJtDHp49hT8Gt07h/cwmvVQ3smXgaN7P/snFjpyOH9FAw0qOViiaBgtWB 3D+fiEfEFXQG5+Dq1OD/KUV6vJze6qK6D9wo7RSk= Received: from arkena.com (unknown [172.16.3.159]) by secu2 (Postfix) with ESMTP id 6C5773FA71; Mon, 12 Feb 2018 12:39:29 +0100 (CET) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Feb 2018 10:48:27 +0100 Message-Id: <20180212094830.9304-5-nicolas.gaullier@arkena.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180212094830.9304-1-nicolas.gaullier@arkena.com> References: <20180212094830.9304-1-nicolas.gaullier@arkena.com> Subject: [FFmpeg-devel] [PATCH v2 5/8] avfilter/silencedetect: fix silence_end accuracy 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: nicolas gaullier MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: nicolas gaullier --- libavfilter/af_silencedetect.c | 3 ++- tests/ref/fate/filter-metadata-silencedetect | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 749c3fbcb7..8973049fe5 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -92,7 +92,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, } } else { if (s->start[channel] > INT64_MIN) { - int64_t end_pts = insamples->pts; + int64_t end_pts = insamples->pts + av_rescale_q(current_sample / s->channels, + (AVRational){ 1, s->last_sample_rate }, time_base); int64_t duration_ts = end_pts - s->start[channel]; set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", av_ts2timestr(end_pts, &time_base)); diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect index 917b836250..e4be2ffac7 100644 --- a/tests/ref/fate/filter-metadata-silencedetect +++ b/tests/ref/fate/filter-metadata-silencedetect @@ -17,7 +17,7 @@ pkt_pts=4800 pkt_pts=5120 pkt_pts=5440 pkt_pts=5760 -pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.38 +pkt_pts=6080|tag:lavfi.silence_end=0.384813|tag:lavfi.silence_duration=0.384813 pkt_pts=6400 pkt_pts=6720 pkt_pts=7040 @@ -97,7 +97,7 @@ pkt_pts=30400 pkt_pts=30720 pkt_pts=31040 pkt_pts=31360 -pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.792438 +pkt_pts=31680|tag:lavfi.silence_end=1.99538|tag:lavfi.silence_duration=0.807813 pkt_pts=32000 pkt_pts=32320 pkt_pts=32640 @@ -196,7 +196,7 @@ pkt_pts=62080 pkt_pts=62400 pkt_pts=62720 pkt_pts=63040 -pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.015 +pkt_pts=63360|tag:lavfi.silence_end=3.97138|tag:lavfi.silence_duration=1.02638 pkt_pts=63680 pkt_pts=64000 pkt_pts=64320 @@ -270,7 +270,7 @@ pkt_pts=85760 pkt_pts=86080 pkt_pts=86400 pkt_pts=86720 -pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.683375 +pkt_pts=87040|tag:lavfi.silence_end=5.45|tag:lavfi.silence_duration=0.693375 pkt_pts=87360 pkt_pts=87680 pkt_pts=88000 @@ -362,7 +362,7 @@ pkt_pts=115200 pkt_pts=115520 pkt_pts=115840 pkt_pts=116160 -pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.00681 +pkt_pts=116480|tag:lavfi.silence_end=7.28569|tag:lavfi.silence_duration=1.0125 pkt_pts=116800 pkt_pts=117120 pkt_pts=117440 @@ -452,7 +452,7 @@ pkt_pts=144000 pkt_pts=144320 pkt_pts=144640 pkt_pts=144960 -pkt_pts=145280|tag:lavfi.silence_end=9.08|tag:lavfi.silence_duration=0.828937 +pkt_pts=145280|tag:lavfi.silence_end=9.08156|tag:lavfi.silence_duration=0.8305 pkt_pts=145600 pkt_pts=145920 pkt_pts=146240