From patchwork Mon May 6 12:41:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 13005 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 7A3A2448F13 for ; Mon, 6 May 2019 15:41:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F96068AAF5; Mon, 6 May 2019 15:41:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 70E8068AAA2 for ; Mon, 6 May 2019 15:41:48 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id m20so5370314wmg.1 for ; Mon, 06 May 2019 05:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=9w72u7UQkUUll6AmnNvDsS92nCY0wa8yuKddnqyfppI=; b=KBNGxyp/u6BjBW786DtUXNDPljpHPO8C69Yw6i7SVoDqrOentnmWbqtAwI783NAVab b5ZdLC/PsK8czjBF/47mM3IM7PSgLR+SNCklEnx1BBBU5UTdbYgng+9XD6uU8LvxkKbK t7FehBC7WfF5LhMvu4ostF9QERdy1fuDcQ41+TbC9t9wLDWNlxugDYhRtCsnaZOvmpkd Mgss0RKA4OgUHdjSBUn/bD/q6vL47fnMRcK69pqnaNAhl82xCfhZWZTnSehu6qlt91tQ a/wjVv9MncnI6c5zoWEH57gex5AA/dI1j7Rpws3ZaIKGcSXIHl3kI6OW8O+kYnvmdlg7 jX0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=9w72u7UQkUUll6AmnNvDsS92nCY0wa8yuKddnqyfppI=; b=BxRoVpyA8GQdMehyydq97TxC9Vb2vDSxGwVJjWHlqljP9//IWbTv8IkeS66qCZbd5L ZE0gz3BDX1flBGnK1MC2ukgdcR8+3tm1e0JyFQ7a5RvUiRlh/pVjiBBpE90ene9cwi5n I7XbgJtty1rUK/l4KYXkSpCU/kOBPCc3b8tDSwfAdRJQkL7BVD7QAw5uZ/nBt7MRrrH0 KYQhiryq0PtSX51n7sp98szXjTZdC7mVe4tHpdcdzZDK2ZBQMnlKL/ZfASYs7u88QlWg Vk7oFSnZ9GBkew49lb6aBNPn1WWBDGV+Mn4Nem5xTBLMPX1y/BMzeW/2RsJrp1AQzRM4 cRXg== X-Gm-Message-State: APjAAAWThMOSNWjZwaKrU7OJqXmMC8pIPYlZnHfP9lYPDMp3XcVdqmlH iu6ObQUPSPWkOZWhVWLN77L+2DIM X-Google-Smtp-Source: APXvYqyGkIqEqotZ/z6TQGz23YpnMuoPQ0L75r8IEkzhOBA/ezwrScerYXyo8COWmLb3PkusMLdgzw== X-Received: by 2002:a1c:e916:: with SMTP id q22mr16477172wmc.148.1557146507642; Mon, 06 May 2019 05:41:47 -0700 (PDT) Received: from localhost.localdomain ([37.244.241.103]) by smtp.gmail.com with ESMTPSA id c20sm10643477wre.28.2019.05.06.05.41.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 05:41:46 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Mon, 6 May 2019 14:41:33 +0200 Message-Id: <20190506124133.25596-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avfilter/af_atempo: offset all output timestamps by same amount of first input timestamp 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- Makes ffplay display correct timestamps when seeking. --- libavfilter/af_atempo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index bfdad7d76b..6a23d59641 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; @@ -1055,6 +1058,7 @@ static int config_props(AVFilterLink *inlink) enum AVSampleFormat format = inlink->format; int sample_rate = (int)inlink->sample_rate; + atempo->start_pts = AV_NOPTS_VALUE; return yae_reset(atempo, format, sample_rate, inlink->channels); } @@ -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,8 @@ 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 = src_buffer->pts; while (src < src_end) { if (!atempo->dst_buffer) { atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out);