From patchwork Thu Sep 7 08:59:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 5026 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp1673038jao; Thu, 7 Sep 2017 02:00:08 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5hvbpnhApmaaGRe/QaxMtzw1TkWvAQT8y3G9BsGyxXBP6+VyC7lb99mhZNFi1rOhPVzZ/K X-Received: by 10.28.154.88 with SMTP id c85mr117542wme.59.1504774808628; Thu, 07 Sep 2017 02:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774808; cv=none; d=google.com; s=arc-20160816; b=pPInujPgO0owSNqv0CVyBtYiv6Y7kW9dZLHGqlHyCupy17u5HdbcEq5Xq+8fz1RPxY ONwh85R0evLYalQyv7GIkdMqSkR+39FuhdaCwe8kY20I+h+NatAEyFTRPypmBOdgX8fu kS2fyhQdCPBDM5iRd8QI30dbNlmicZl8wYJkKQpNUUauZBao5yUwlJ69pUqOQSG9T4Sq X30+JvYz5Zxz76uDVfBwv8nZAqoWxkQFxGNBzD2HeEuhM1WS5Vx+28F069bdvGWleI+x I8NbR0oAIdYCSHESDJ9t0pMJ4oaTYA570k5LHdCWvz8oRwpWdlhrYR8bLXLr4Xte1sVp 5aiA== 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: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:delivered-to:arc-authentication-results; bh=ADB1oOMJjL+pn7k0cTsvw09JOXDkbx5eCCJuZl72arQ=; b=Ek5mFJ89R4dPKZvWWzdWFm1D8lVqrxMxTnX29LN5ZiI5dMZbOiXFXG546ruNFxNq4Z Vcce94tQRxmGMKc5hY1U8m5Vy7UdJ1JTP8qCFKlGWRTSbbzhnpQ6kJ2iePwnpkpIMQHp jYwFNO8zlIrTx0tgRw6zUoYlQ+4N1oNbwUOfxZJNNzVOssdZu33L58H2zkM+vWX5Zq7c 9jRGG7WX2HQe6OGrLuG3VMj+TYCFDAw9qY8cxw851w0VWkdLywLMxYrKAB4BJcl2iNxr XG4mjcYZbDkQoJnAgtf7MrvVJYHKhZxdObGUyvBH05XqOnj3ickuHVHiPOwwycKEx0/C taQA== ARC-Authentication-Results: i=1; mx.google.com; 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 j140si18557wmf.34.2017.09.07.02.00.08; Thu, 07 Sep 2017 02:00:08 -0700 (PDT) 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; 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 1F52D689E20; Thu, 7 Sep 2017 11:59:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B9DC689DF6 for ; Thu, 7 Sep 2017 11:59:38 +0300 (EEST) Received: from phare.normalesup.org (archicubes.ens.fr [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v878xf5a089839 for ; Thu, 7 Sep 2017 10:59:41 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 8EE89E00D0; Thu, 7 Sep 2017 10:59:41 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2017 10:59:37 +0200 Message-Id: <20170907085939.21770-3-george@nsup.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170907085939.21770-1-george@nsup.org> References: <20170907085939.21770-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Thu, 07 Sep 2017 10:59:41 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 3/5] ffmpeg: use reordered duration for stream PTS. 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: Nicolas George --- ffmpeg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index c8ee64621c..b95addd277 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2368,7 +2368,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, return err < 0 ? err : ret; } -static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eof, +static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof, int *decode_failed) { AVFrame *decoded_frame; @@ -2459,6 +2459,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eo ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; best_effort_timestamp= decoded_frame->best_effort_timestamp; + *duration_pts = decoded_frame->pkt_duration; if (ist->framerate.num) best_effort_timestamp = ist->cfr_next_pts++; @@ -2629,6 +2630,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo // while we have more to decode or while the decoder did output something on EOF while (ist->decoding_needed) { int64_t duration_dts = 0; + int64_t duration_pts = 0; int got_output = 0; int decode_failed = 0; @@ -2641,7 +2643,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo &decode_failed); break; case AVMEDIA_TYPE_VIDEO: - ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, !pkt, + ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, &duration_pts, !pkt, &decode_failed); if (!repeating || !pkt || got_output) { if (pkt && pkt->duration) { @@ -2660,7 +2662,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } if (got_output) - ist->next_pts += duration_dts; //FIXME the duration is not correct in some cases + ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); break; case AVMEDIA_TYPE_SUBTITLE: if (repeating)