From patchwork Thu Apr 6 08:44:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 3315 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp555462vss; Thu, 6 Apr 2017 01:45:15 -0700 (PDT) X-Received: by 10.28.61.198 with SMTP id k189mr23721362wma.71.1491468315311; Thu, 06 Apr 2017 01:45:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 6si1954280wmf.160.2017.04.06.01.45.14; Thu, 06 Apr 2017 01:45:15 -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 094F368835E; Thu, 6 Apr 2017 11:45:00 +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 71C67680CCC for ; Thu, 6 Apr 2017 11:44:53 +0300 (EEST) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v368it60047368 for ; Thu, 6 Apr 2017 10:44:56 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id CD2C1E8C4D; Thu, 6 Apr 2017 10:44:55 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Apr 2017 10:44:49 +0200 Message-Id: <20170406084451.27892-2-george@nsup.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170406084451.27892-1-george@nsup.org> References: <20170406084451.27892-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, 06 Apr 2017 10:44:56 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 2/4] 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(-) Unchanged. Necessary for the next patches. diff --git a/ffmpeg.c b/ffmpeg.c index 4db8ea82ac..41f1f076ca 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2357,7 +2357,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, int *duration_pts, int eof, int *decode_failed) { AVFrame *decoded_frame; @@ -2448,6 +2448,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= av_frame_get_best_effort_timestamp(decoded_frame); + *duration_pts = decoded_frame->pkt_duration; if (ist->framerate.num) best_effort_timestamp = ist->cfr_next_pts++; @@ -2618,6 +2619,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) { int duration_dts = 0; + int duration_pts = 0; int got_output = 0; int decode_failed = 0; @@ -2630,7 +2632,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) { @@ -2649,7 +2651,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)