From patchwork Wed May 8 04:53:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Koshevoy X-Patchwork-Id: 13028 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B0D96447BF7 for ; Wed, 8 May 2019 07:54:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8AC2D68A543; Wed, 8 May 2019 07:54:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BFA9668A4BD for ; Wed, 8 May 2019 07:53:59 +0300 (EEST) Received: by mail-pg1-f178.google.com with SMTP id e6so9458536pgc.4 for ; Tue, 07 May 2019 21:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OTevwwZ7Iom7kHcsFNC9Gm0MUUSGTWX77EpCc+HXDZE=; b=UR3FEdsDj7+44GHctCL284pNkLWh4ayL5RYBTXW6KODmfER0bQIMroqLsTllMROGnh shBzXfKBf3Fbw+dUw9gojzBIEDscrCqiWo7jGf7FP81jFs59RAdpW/RD2BGzipGcNlFo oG0+V0t7sfkXuQF+IVrhP9+04xH6fqKNECXVMY14C8UUAtaQz5sD/pY51Cr3un2FJJZ6 ea4yXR8kAFjDDqiob9HaJSOgjBwiBDk5iJLQzYqlx7L+fFPEWkNNaakp1TKHGFF6MM7T jgcvVgOWT18EyOT8MMXqPaRNY+v4AMjGUZQ6OHzDKXDh/uMtc3WMR8xCERJtymIuHI2G Ky6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OTevwwZ7Iom7kHcsFNC9Gm0MUUSGTWX77EpCc+HXDZE=; b=J38+COQOycvMUl4cdk9CnI2ztc2xeji79F6Yv2BbVVZpUQzyQyjsxsQJ11NQkm6hFi G2IlGT5ghNoHrkeSRawl/IyIlsT8o55rEbcosUci7tB09VJ+qyZuDp8PP+wpbzjuX1Mu 2SYubEB3HThlMQUAVNVsPAOc668nJIEtdGyVfssADJdTkmfg4729PfkY3HXDKuWwbSSd BvDFcBBDL7NuY2SKi+0gE2nsbCSS4yNovkCAWc7XvgzwOQYwBhJLt6YKSpfgvjSjRJaK kPPrRKrKQ9QjDCwR0RR9oIP/+xWf6dz3CeR2rQ39zva4OF15ptek6coYzhVJY8bJsX3O 74yg== X-Gm-Message-State: APjAAAUiMxtprcP8NVKnGMSipFwzm2yfO+5t9Vyj4IWBQgC8iFAPEw5K +XhegEuquVZZ6E4UP61JlgRYTlNZqiE= X-Google-Smtp-Source: APXvYqzkTV4PllOCeUm6mTHrpyFpTR7Xm617eKf+dlh/NPKThNWG/4gicCdvb6VEpNieBb+EL8SxWw== X-Received: by 2002:aa7:8455:: with SMTP id r21mr47070292pfn.253.1557291237448; Tue, 07 May 2019 21:53:57 -0700 (PDT) Received: from homestead.aragog.com ([2605:a601:a9ae:9100:12c3:7bff:fe6c:2700]) by smtp.gmail.com with ESMTPSA id o2sm31043373pgq.1.2019.05.07.21.53.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 21:53:56 -0700 (PDT) From: Pavel Koshevoy To: ffmpeg-devel@ffmpeg.org Date: Tue, 7 May 2019 22:53:55 -0600 Message-Id: <20190508045355.12091-1-pkoshevoy@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506124133.25596-1-onemda@gmail.com> References: <20190506124133.25596-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH] avfilter/af_atempo: Make ffplay display correct timestamps when seeking 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: Pavel Koshevoy MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" NOTE: this is a refinement of the patch from Paul B Mahol offset all output timestamps by same amount of first input timestamp --- libavfilter/af_atempo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index bfdad7d76b..688dac5464 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -103,6 +103,9 @@ typedef struct ATempoContext { // 1: output sample position int64_t position[2]; + // first input timestamp, all other timestamps are offset by this one + int64_t start_pts; + // sample format: enum AVSampleFormat format; @@ -186,6 +189,7 @@ static void yae_clear(ATempoContext *atempo) atempo->nfrag = 0; atempo->state = YAE_LOAD_FRAGMENT; + atempo->start_pts = AV_NOPTS_VALUE; atempo->position[0] = 0; atempo->position[1] = 0; @@ -1068,7 +1072,7 @@ static int push_samples(ATempoContext *atempo, atempo->dst_buffer->nb_samples = n_out; // adjust the PTS: - atempo->dst_buffer->pts = + atempo->dst_buffer->pts = atempo->start_pts + av_rescale_q(atempo->nsamples_out, (AVRational){ 1, outlink->sample_rate }, outlink->time_base); @@ -1097,6 +1101,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer) const uint8_t *src = src_buffer->data[0]; const uint8_t *src_end = src + n_in * atempo->stride; + if (atempo->start_pts == AV_NOPTS_VALUE) + atempo->start_pts = av_rescale_q(src_buffer->pts, + inlink->time_base, + outlink->time_base); + while (src < src_end) { if (!atempo->dst_buffer) { atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out);