From patchwork Thu Jan 24 12:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Wegner?= X-Patchwork-Id: 11856 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 840FF44EC05 for ; Thu, 24 Jan 2019 14:49:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A362F68AD25; Thu, 24 Jan 2019 14:49:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9306268AD25 for ; Thu, 24 Jan 2019 14:48:55 +0200 (EET) Received: by mail-lj1-f194.google.com with SMTP id n18-v6so5104502lji.7 for ; Thu, 24 Jan 2019 04:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gpfNqBNCR2mib4PuiIYVRYpEMTwZ/cf7063PmXwkF5A=; b=oTOL4lHQfSo4olPiTydUY4kh4t3GJn5OR+AJc6zFcp1dfN8pMXsj46bn0Sfxdxet6T Qs/SrUVW+SDMi1FCoeYII97PM+lSLVMhHHMkvudmUjTHls3EBHhrSWlZBOMsedJIJ0c1 uYAp+iN8/Ij3TjR54//ucMn8R0yct8HtX0It7Y+laZDGbKz9lrDkfUCG3sREKVnxR/qQ eug6YEVzliIgvBHze2HXb4E2lBsHchzNC1aM8J9K5V4MpW3IdixUCqenUeJYek55lkye IBnu856o4ojVENnFVc9+tTGlWCUd97sc+5NI8GlP7TK5AQAAoh8rTVAnBmZ/ymK9+lnf TuBQ== 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:mime-version :content-transfer-encoding; bh=gpfNqBNCR2mib4PuiIYVRYpEMTwZ/cf7063PmXwkF5A=; b=JHJqg8dm6gfm+/BVrXhUFM3syhrbrC5on0dkZ9uT5W+0ITXI8BG/i8jtSdGg4AKY3h PfZabT6rY5u+cfh+aXW/OgDTZtidEkqZExVaLBlc9AGmjSX3G4hgBnHhmRLDPZuxpkxK zaaVgEW3j8X3sELDaIbrIMi2ek2vB5k/8NLLakDcCBNubz8vaD4y+idQY5JAJ6GLrq0e wdb8kXZRQ5O7J1u8Wu+yIkdI1M1SJFbCyVGh2QjkxZJXsvxCtLPG9pNhzZc353FyLYg1 xYco7PheAygFmDgKaUyYNMQ1AwKFLSLEoMus3Ydgx3KfbgtTZ6/TcuS5KWNyB+XWJZxl QLZw== X-Gm-Message-State: AJcUukfLEteMJ/6MRyTXmaqeL0BUKdM+LkpeO+GyV1KDYKLSptdALW8T c3GW7ZU17pRf354rYS5OMSA7Z+cy X-Google-Smtp-Source: ALg8bN6lsX12V7kJ8fG+AQhpwYaxqzWlkQ/K7w9ai3hk5xubhSaVOXeujAwpRzyu7gti1ffL0csvUQ== X-Received: by 2002:a2e:9715:: with SMTP id r21-v6mr5590394lji.30.1548333730927; Thu, 24 Jan 2019 04:42:10 -0800 (PST) Received: from localhost (89-70-125-176.dynamic.chello.pl. [89.70.125.176]) by smtp.gmail.com with ESMTPSA id l3-v6sm1001451ljg.21.2019.01.24.04.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 04:42:10 -0800 (PST) From: =?UTF-8?q?Pawe=C5=82=20Wegner?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Jan 2019 13:42:03 +0100 Message-Id: <20190124124203.19345-1-pawel.wegner95@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavfilter/af_atempo: offset output frames' pts by first_frame_pts / tempo 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: =?UTF-8?q?Pawe=C5=82=20Wegner?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paweł Wegner --- libavfilter/af_atempo.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index bfdad7d76b..1245eae8c1 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -147,6 +147,8 @@ typedef struct ATempoContext { uint8_t *dst_end; uint64_t nsamples_in; uint64_t nsamples_out; + + int64_t first_frame_pts; } ATempoContext; #define YAE_ATEMPO_MIN 0.5 @@ -994,6 +996,7 @@ static av_cold int init(AVFilterContext *ctx) ATempoContext *atempo = ctx->priv; atempo->format = AV_SAMPLE_FMT_NONE; atempo->state = YAE_LOAD_FRAGMENT; + atempo->first_frame_pts = AV_NOPTS_VALUE; return 0; } @@ -1069,6 +1072,7 @@ static int push_samples(ATempoContext *atempo, // adjust the PTS: atempo->dst_buffer->pts = + (atempo->first_frame_pts == AV_NOPTS_VALUE ? 0 : atempo->first_frame_pts / atempo->tempo) + av_rescale_q(atempo->nsamples_out, (AVRational){ 1, outlink->sample_rate }, outlink->time_base); @@ -1108,6 +1112,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer) atempo->dst = atempo->dst_buffer->data[0]; atempo->dst_end = atempo->dst + n_out * atempo->stride; + + if (atempo->first_frame_pts == AV_NOPTS_VALUE) + atempo->first_frame_pts = av_rescale_q(atempo->dst_buffer->pts, + inlink->time_base, + outlink->time_base); } yae_apply(atempo, &src, src_end, &atempo->dst, atempo->dst_end);